在數值分析 上,梯形法則 和辛卜生法則 均是數值積分 的方法。它們都是計算定積分 的。
這兩種方法都屬於牛頓-寇次公式 。它們以函數於等距 n + 1 {\displaystyle n+1} 點的值,取得一個n {\displaystyle n} 次的多項式 來近似原來的函數,再行求積。
梯形法則
编辑
原函數(藍色)近似為紅色的線性函數 多重梯形法則 梯形法則 是:
∫ a b f ( x ) d x ≈ ( b − a ) f ( a ) + f ( b ) 2 . {\displaystyle \int _{a}^{b}f(x)\,dx\approx (b-a){\frac {f(a)+f(b)}{2}}.} 這等同將被積函數近似為直線 函數,被積的部分近似為梯形 。
要求得較準確的數值,可以將要求積的區間分成多個小區間,再個別估計,即:
∫ a b f ( x ) d x ≈ b − a n ( f ( a ) + f ( b ) 2 + ∑ k = 1 n − 1 f ( a + k b − a n ) ) . {\displaystyle \int _{a}^{b}f(x)\,dx\approx {\frac {b-a}{n}}\left({f(a)+f(b) \over 2}+\sum _{k=1}^{n-1}f\left(a+k{\frac {b-a}{n}}\right)\right).} 可改寫成
∫ a b f ( x ) d x ≈ b − a 2 n ( f ( x 0 ) + 2 f ( x 1 ) + 2 f ( x 2 ) + ⋯ + 2 f ( x n − 1 ) + f ( x n ) ) {\displaystyle \int _{a}^{b}f(x)\,dx\approx {\frac {b-a}{2n}}\left(f(x_{0})+2f(x_{1})+2f(x_{2})+\cdots +2f(x_{n-1})+f(x_{n})\right)} 其中
對k = 0 , 1 , … , n {\displaystyle k=0,1,\dots ,n} ,x k = a + k b − a n , {\displaystyle x_{k}=a+k{\frac {b-a}{n}},} 。 辛普森法则
编辑
辛普森法则 (Simpson's rule,又稱森遜法則 )是:
∫ a b f ( x ) d x ≈ b − a 6 [ f ( a ) + 4 f ( a + b 2 ) + f ( b ) ] . {\displaystyle \int _{a}^{b}f(x)\,dx\approx {\frac {b-a}{6}}\left[f(a)+4f\left({\frac {a+b}{2}}\right)+f(b)\right].} 同樣地,辛普森法则也有多重的版本:
∫ a b f ( x ) d x ≈ h 3 ⋅ [ f ( x 0 ) + 2 ∑ k = 1 n − 1 f ( x k ) + 4 ∑ k = 1 n f ( x k − 1 + x k 2 ) + f ( x n ) ] {\displaystyle \int _{a}^{b}f(x)\,dx\approx {\frac {h}{3}}\cdot \left[f(x_{0})+2\sum _{k=1}^{n-1}f(x_{k})+4\sum _{k=1}^{n}f\left({\frac {x_{k-1}+x_{k}}{2}}\right)+f(x_{n})\right]} h = b − a n , x k = a + k ⋅ h . {\displaystyle h={\frac {b-a}{n}},\ x_{k}=a+k\cdot h.} 或寫成
∫ a b f ( x ) d x ≈ h 3 [ f ( x 0 ) + 4 f ( x 1 ) + 2 f ( x 2 ) + 4 f ( x 3 ) + 2 f ( x 4 ) + ⋯ + 4 f ( x n − 1 ) + f ( x n ) ] {\displaystyle \int _{a}^{b}f(x)\,dx\approx {\frac {h}{3}}{\bigg [}f(x_{0})+4f(x_{1})+2f(x_{2})+4f(x_{3})+2f(x_{4})+\cdots +4f(x_{n-1})+f(x_{n}){\bigg ]}} 牛頓-寇次公式
编辑
牛頓-寇次公式(Newton-Cotes rule / Newton-Cotes formula)以Roger Cotes和艾薩克·牛頓 命名。其內容是:
∫ a b f ( x ) d x ≈ ∑ i = 0 n w i f ( x i ) {\displaystyle \int _{a}^{b}f(x)\,dx\approx \sum _{i=0}^{n}w_{i}\,f(x_{i})}
其中對k = 0 , 1 , … , n {\displaystyle k=0,1,\dots ,n} ,w i {\displaystyle w_{i}} 是常數(由n {\displaystyle n} 的值決定),x k = a + k b − a n {\displaystyle x_{k}=a+k{\frac {b-a}{n}}} 。
梯形法則和辛卜生法則便是n = 1 , 2 {\displaystyle n=1,2} 的情況。
亦有不採用在邊界點來估計的版本,即取 x k = a + k b − a n + 1 {\displaystyle x_{k}=a+k{\frac {b-a}{n+1}}} 。
假設已知f ( x 0 ) , f ( x 1 ) , … , f ( x n ) {\displaystyle f(x_{0}),f(x_{1}),\dots ,f(x_{n})} 的值。
以n + 1 {\displaystyle n+1} 點進行插值 ,求得對應f ( x ) {\displaystyle f(x)} 的拉格朗日多項式 。
對該n {\displaystyle n} 次的多項式求積。 該積分便可以作為∫ a b f ( x ) d x {\displaystyle \int _{a}^{b}f(x)\,dx} 的近似,而由於該拉格朗日多項式的係數都是常數(由n {\displaystyle n} 決定其值),所以積函數的係數(即w i {\displaystyle w_{i}} )都是常數。
對於次數較高的多項式而有很大誤差(龍格現象 ),不如高斯積分法 。
下表中f i = f ( x i ) {\displaystyle f_{i}=f(x_{i})} ,ξ ∈ [ a , b ] {\displaystyle \xi \in [a,b]} ,h = b − a {\displaystyle h=b-a}
精度
名稱
公式
誤差
1
梯形法則
h 2 ( f 0 + f 1 ) {\displaystyle {\frac {h}{2}}(f_{0}+f_{1})}
− 2 h 3 3 f ( 2 ) ( ξ ) {\displaystyle -{\frac {2h^{3}}{3}}\,f^{(2)}(\xi )}
2
辛卜生法則
h 6 ( f 0 + 4 f 1 + f 2 ) {\displaystyle {\frac {h}{6}}(f_{0}+4f_{1}+f_{2})}
− h 5 90 f ( 4 ) ( ξ ) {\displaystyle -{\frac {h^{5}}{90}}\,f^{(4)}(\xi )}
3
辛卜生3/8法則 辛卜生第二法則
h 8 ( f 0 + 3 f 1 + 3 f 2 + f 3 ) {\displaystyle {\frac {h}{8}}(f_{0}+3f_{1}+3f_{2}+f_{3})}
− 3 h 5 80 f ( 4 ) ( ξ ) {\displaystyle -{\frac {3h^{5}}{80}}\,f^{(4)}(\xi )}
4
保爾法則 (Boole's rule / Bode's rule)
2 h 45 ( 7 f 0 + 32 f 1 + 12 f 2 + 32 f 3 + 7 f 4 ) {\displaystyle {\frac {2h}{45}}(7f_{0}+32f_{1}+12f_{2}+32f_{3}+7f_{4})}
− 8 h 7 945 f ( 6 ) ( ξ ) {\displaystyle -{\frac {8h^{7}}{945}}\,f^{(6)}(\xi )}
不用界點的
0
中點法
2 h f 1 {\displaystyle 2hf_{1}\,}
h 3 24 f ( 2 ) ( ξ ) {\displaystyle {\frac {h^{3}}{24}}\,f^{(2)}(\xi )}
1
3 h 2 ( f 1 + f 2 ) {\displaystyle {\frac {3h}{2}}(f_{1}+f_{2})}
h 3 4 f ( 2 ) ( ξ ) {\displaystyle {\frac {h^{3}}{4}}\,f^{(2)}(\xi )}
2
4 h 3 ( 2 f 1 − f 2 + 2 f 3 ) {\displaystyle {\frac {4h}{3}}(2f_{1}-f_{2}+2f_{3})}
28 h 5 90 f ( 4 ) ( ξ ) {\displaystyle {\frac {28h^{5}}{90}}f^{(4)}(\xi )}
3
5 h 24 ( 11 f 1 + f 2 + f 3 + 11 f 4 ) {\displaystyle {\frac {5h}{24}}(11f_{1}+f_{2}+f_{3}+11f_{4})}
95 h 5 144 f ( 4 ) ( ξ ) {\displaystyle {\frac {95h^{5}}{144}}f^{(4)}(\xi )}
M. Abramowitz and I. A. Stegun, eds. Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables . New York: Dover, 1972. (See Section 25.4.)
George E. Forsythe, Michael A. Malcolm, and Cleve B. Moler. Computer Methods for Mathematical Computations . Englewood Cliffs, NJ: Prentice-Hall, 1977. (See Section 5.1.)
William H. Press, Brian P. Flannery, Saul A. Teukolsky, William T. Vetterling. Numerical Recipes in C . Cambridge, UK: Cambridge University Press, 1988. (See Section 4.1.)
Josef Stoer and Roland Bulirsch. Introduction to Numerical Analysis . New York: Springer-Verlag, 1980. (See Section 3.1.) 外部連結
编辑