1)
∫ 0 π / 4 x s i n x d x = − x c o s x ∣ 0 π / 4 + ∫ 0 π / 4 c o s x d x = \int^{\pi/4}_0 xsinx dx=-xcosx|^{\pi/4}_0+\int^{\pi/4}_0 cosx dx= ∫ 0 π /4 x s in x d x = − x cos x ∣ 0 π /4 + ∫ 0 π /4 cos x d x =
= − x c o s x ∣ 0 π / 4 + s i n x ∣ 0 π / 4 = − π 4 2 + 1 2 = 0.152 =-xcosx|^{\pi/4}_0+sinx|^{\pi/4}_0=-\frac{\pi}{4\sqrt 2}+\frac{1}{\sqrt 2}=0.152 = − x cos x ∣ 0 π /4 + s in x ∣ 0 π /4 = − 4 2 π + 2 1 = 0.152
2)
f ( x ) = x s i n x f(x)=xsinx f ( x ) = x s in x
I = ( b − a ) f ( a ) + f ( b ) 2 = π 4 π 2 ⋅ 4 2 = 0.436 I=(b-a)\frac{f(a)+f(b)}{2}=\frac{\pi}{4}\frac{\pi}{2\cdot4\sqrt 2}=0.436 I = ( b − a ) 2 f ( a ) + f ( b ) = 4 π 2 ⋅ 4 2 π = 0.436
3)
for n = 2:
I = π 8 ( f ( 0 ) + f ( π / 8 ) 2 + f ( π / 8 ) + f ( π / 4 ) 2 ) = π 8 ( π s i n ( π / 8 ) / 8 + π s i n ( π / 4 ) / 8 ) = 0.021 I=\frac{\pi}{8}(\frac{f(0)+f(\pi/8)}{2}+\frac{f(\pi/8)+f(\pi/4)}{2})=\frac{\pi}{8}(\pi sin(\pi/8)/8+\pi sin(\pi/4)/8)=0.021 I = 8 π ( 2 f ( 0 ) + f ( π /8 ) + 2 f ( π /8 ) + f ( π /4 ) ) = 8 π ( π s in ( π /8 ) /8 + π s in ( π /4 ) /8 ) = 0.021
for n = 4:
I = π 16 ( f ( 0 ) + f ( π / 16 ) 2 + f ( π / 16 ) + f ( π / 8 ) 2 + f ( π / 8 ) + f ( 3 π / 16 ) 2 + f ( 3 π / 16 ) + f ( π / 4 ) 2 ) = I=\frac{\pi}{16}(\frac{f(0)+f(\pi/16)}{2}+\frac{f(\pi/16)+f(\pi/8)}{2}+\frac{f(\pi/8)+f(3\pi/16)}{2}+\frac{f(3\pi/16)+f(\pi/4)}{2})= I = 16 π ( 2 f ( 0 ) + f ( π /16 ) + 2 f ( π /16 ) + f ( π /8 ) + 2 f ( π /8 ) + f ( 3 π /16 ) + 2 f ( 3 π /16 ) + f ( π /4 ) ) =
= π 16 ( π s i n ( π / 16 ) / 16 + π s i n ( π / 8 ) / 8 + 3 π s i n ( 3 π / 16 ) / 16 + π s i n ( π / 4 ) / 8 ) = =\frac{\pi}{16}(\pi sin(\pi/16)/16+\pi sin(\pi/8)/8+3\pi sin(3\pi/16)/16+\pi sin(\pi/4)/8)= = 16 π ( π s in ( π /16 ) /16 + π s in ( π /8 ) /8 + 3 π s in ( 3 π /16 ) /16 + π s in ( π /4 ) /8 ) =
= 0.616 ( 0.012 + 0.048 + 0.104 + 0.88 ) = 0.155 =0.616(0.012+0.048+0.104+0.88)=0.155 = 0.616 ( 0.012 + 0.048 + 0.104 + 0.88 ) = 0.155
relative error:
for single application:
0.436 − 0.152 0.152 = 1.87 = 187 % \frac{0.436-0.152}{0.152}=1.87=187\% 0.152 0.436 − 0.152 = 1.87 = 187%
for n = 2:
0.152 − 0.021 0.152 = 0.86 = 86 % \frac{0.152-0.021}{0.152}=0.86=86\% 0.152 0.152 − 0.021 = 0.86 = 86%
for n = 4:
0.155 − 0.152 0.152 = 0.02 = 2 % \frac{0.155-0.152}{0.152}=0.02=2\% 0.152 0.155 − 0.152 = 0.02 = 2%
Comments