第八章:数值积分和数值微分
![image-20210104154005483](https://typora-1301295568.cos.ap-guangzhou.myqcloud.com/img/image-20210104154005483.png)
![image-20210104154033667](https://typora-1301295568.cos.ap-guangzhou.myqcloud.com/img/image-20210104154033667.png)
![image-20210104154247033](https://typora-1301295568.cos.ap-guangzhou.myqcloud.com/img/image-20210104154247033.png)
![image-20210104154317702](https://typora-1301295568.cos.ap-guangzhou.myqcloud.com/img/image-20210104154317702.png)
![image-20210104154133729](https://typora-1301295568.cos.ap-guangzhou.myqcloud.com/img/image-20210104154133729.png)
-
用复化梯形公式计算 ∫ 0 1 2 1 + x 2 d x \int _ { 0 } ^ { 1 } \frac { 2 } { 1 + x ^ { 2 } } d x ∫011+x22dx,使其截断误差不超过0.01.
f ( x ) = 2 1 + x 2 f(x)=\frac{2}{1+x^2} f(x)=1+x22
d d x ( 2 1 + x 2 ) = − 4 x ( 1 + x 2 ) 2 \frac { d } { d x } ( \frac { 2 } { 1 + x ^ { 2 } } ) = - \frac { 4 x } { ( 1 + x ^ { 2 } ) ^ { 2 } } dxd(1+x22)=−(1+x2)24x
d d x ( − 4 x ( 1 + x 2 ) 2 ) = − 4 ( − 3 x 2 + 1 ) ( 1 + x 2 ) 3 \frac { d } { d x } ( - \frac { 4 x } { ( 1 + x ^ { 2 } ) ^ { 2 } } ) = - \frac { 4 ( - 3 x ^ { 2 } + 1 ) } { ( 1 + x ^ { 2 } ) ^ { 3 } } dxd(−(1+x2)24x)=−(1+x2)34(−3x2+1)
f ′ ′ ( η ) = − 4 ( − 3 x 2 + 1 ) ( 1 + x 2 ) 3 f ^ { \prime \prime } ( \eta )= - \frac { 4 ( - 3 x ^ { 2 } + 1 ) } { ( 1 + x ^ { 2 } ) ^ { 3 } } f′′(η)=−(1+x2)34(−3x2+1)
记 M 2 = max a ⩽ x ⩽ b ∣ f ′ ′ ( x ) ∣ , 则有 \text { 记 } M_{2}=\max _{a \leqslant x \leqslant b}\left|f^{\prime \prime}(x)\right|, \text { 则有 } 记 M2=maxa⩽x⩽b∣f′′(x)∣, 则有 , M 2 = 4 M_2=4 M2=4,(a=0,b=1)
( b − a ) 3 12 n 2 M 2 < ε \frac { ( b - a ) ^ { 3 } } { 12 n ^ { 2 } } M _ { 2 } < \varepsilon 12n2(b−a)3M2<ε
求得 6 ⩽ n 6 \leqslant n 6⩽n,
记 n n n 等分的复化梯形公式为 T n ( f ) T_{n}(f) Tn(f) 或 T ( h ) , T(h), T(h), 有
T n ( f ) = h ( 1 2 f ( a ) + ∑ i = 1 n − 1 f ( a + i h ) + 1 2 f ( b ) ) T_{n}(f)=h\left(\frac{1}{2} f(a)+\sum_{i=1}^{n-1} f(a+i h)+\frac{1}{2} f(b)\right) Tn(f)=h(21f(a)+i=1∑n−1f(a+ih)+21f(b))
n = 6 n=6 n=6, h = 1 6 h=\frac{1}{6} h=61, T 6 ( f ) = 1 6 ( 1 2 f ( 0 ) + f ( 0 + 1 ∗ h ) + f ( 0 + 2 ∗ h ) + f ( 0 + 3 ∗ h ) + f ( 0 + 4 ∗ h ) + f ( 0 + 5 ∗ h ) + 1 2 f ( 1 ) ) T_6(f)=\frac{1}{6}(\frac{1}{2}f(0)+f(0+1*h)+f(0+2*h)+f(0+3*h)\\+f(0+4*h)+f(0+5*h)+\frac{1}{2}f(1)) T6(f)=61(21f(0)+f(0+1∗h)+f(0+2∗h)+f(0+3∗h)+f(0+4∗h)+f(0+5∗h)+21f(1)),
f ( x ) = 2 1 + x 2 f(x)=\frac{2}{1+x^2} f(x)=1+x22
T 6 ( f ) = 1.56848 T_6(f)=1.56848 T6(f)=1.56848.
准确值: ∫ 0 1 2 1 + x 2 d x = π 2 ( Decimal: 1.57079 … ) \int _ { 0 } ^ { 1 } \frac { 2 } { 1 + x ^ { 2 } } d x = \frac { \pi } { 2 } \quad ( \text { Decimal: } \quad 1.57079 \ldots ) ∫011+x22dx=2π( Decimal: 1.57079…)
- 用逐次分半的复化梯形公式计算 ∫ 0 1 2 1 + x 2 d x \int _ { 0 } ^ { 1 } \frac { 2 } { 1 + x ^ { 2 } } d x ∫011+x22dx,使其截断误差不超过0.01.
复化求积公式是提高精度的一种有效方法,但在使用复化求积公式之前,必须根据复化求积公式的余项进行先验估计,以确定节点数目,从而确定合适的等分步长。因为余项表达式中包含了被积函数的导数,而估计各阶导数的最大值往往是很困难的,且估计的误差上界往往偏大。
所以实际中,常常使用“事后估计误差”的方法,通过区间的逐次分半,在步长逐次分半的过程中,反复利用复化求积公式进行计算,查看相继两次计算结果的差值是否达到要求,直到所求得的积分值满足精度要求。
用T(2n)做为积分I的近似值时,其误差大约为
计算时只需检验是否满足?若不满足,则再把区间分半进行计算,直到满足要求为止 。这样就实现了步长的自动选取。
![image-20210104181029002](https://typora-1301295568.cos.ap-guangzhou.myqcloud.com/img/image-20210104181029002.png)
T ( 1 ) = 1 2 [ f ( 0 ) + f ( 1 ) ] = 1.5 T(1)=\frac{1}{2}[f(0)+f(1)]=1.5 T(1)=21[f(0)+f(1)]=1.5
n = 1 n=1 n=1时
T ( 2 ) = 1 2 T ( n ) + 1 − 0 2 ∗ 1 ( f ( 0 + 1 − 0 2 ∗ 1 ( 2 ∗ 1 − 1 ) ) = 1.55 T(2)=\frac{1}{2}T(n)+\frac{1-0}{2*1}(f(0+\frac{1-0}{2*1}(2*1-1))=1.55 T(2)=21T(n)+2∗11−0(f(0+2∗11−0(2∗1−1))=1.55
T ( 2 ) = 1 2 2 ( f ( 0 ) + 2 f ( 1 2 ) + f ( 1 ) ) = 1.55 T(2) = \frac { 1 } { 2 ^ { 2 } } ( f ( 0 ) + 2 f ( \frac { 1 } { 2 } ) + f ( 1 ) )=1.55 T(2)=221(f(0)+2f(21)+f(1))=1.55
n = 2 n=2 n=2时
T ( 4 ) = 1 2 T ( 2 ) + 1 2 ∗ 2 ( f ( 1 4 ) + f ( 3 4 ) ) T(4)=\frac{1}{2}T(2)+\frac{1}{2*2}(f(\frac{1}{4})+f(\frac{3}{4})) T(4)=21T(2)+2∗21(f(41)+f(43))
T ( 4 ) = 1 2 3 ( f ( 0 ) + 2 f ( 1 4 ) + 2 f ( 2 4 ) + 2 f ( 3 4 ) + f ( 1 ) ) = 1 8 ( 2 + 1 + 16 5 + 64 17 + 64 25 ) = 1.5656 T(4) = \frac { 1 } { 2 ^ { 3 } } ( f ( 0 ) + 2 f ( \frac { 1 } { 4 } ) + 2 f ( \frac { 2 } { 4 } ) + 2 f ( \frac { 3 } { 4 } ) + f ( 1 ) )=\frac { 1 } { 8 } ( 2 + 1 + \frac { 16 } { 5 } + \frac { 64 } { 17 } + \frac { 64 } { 25 } )=1.5656 T(4)=231(f(0)+2f(41)+2f(42)+2f(43)+f(1))=81(2+1+516+1764+2564)=1.5656.
T ( 8 ) = 1 2 4 ( f ( 0 ) + 2 f ( 1 8 ) + 2 f ( 2 8 ) + 2 f ( 3 8 ) + 2 f ( 4 8 ) + 2 f ( 5 8 ) + 2 f ( 6 8 ) + 2 f ( 7 8 ) + f ( 1 ) ) = 1.5695 T(8)=\frac{1}{2^4}(f(0)+2 f ( \frac { 1 } { 8 })+2 f ( \frac { 2 } { 8 })+2 f ( \frac { 3 } { 8 })+2 f ( \frac { 4 } { 8 })+2 f ( \frac { 5 } { 8 })+2 f ( \frac { 6 } { 8 })+2 f ( \frac { 7 } { 8 })+f(1))=1.5695 T(8)=241(f(0)+2f(81)+2f(82)+2f(83)+2f(84)+2f(85)+2f(86)+2f(87)+f(1))=1.5695.
误差: ∣ ( T ( 8 ) − T ( 4 ) ) ∣ = 0.0039 |(T(8)-T(4))|=0.0039 ∣(T(8)−T(4))∣=0.0039.