Numerical Integration Igor Yanovsky (Math 151A TA) 1 Trapezoidal Rule Rb We derive the Trapezoidal rule for approximating a f (x) dx using the Lagrange polynomial method, with the linear Lagrange polynomial. Let x0 = a, x1 = b, and h = b − a. Z x1 Z b = x1 Z 1 x1 00 f (x) dx = P1 (x) dx + f (ξ)(x − x0)(x − x1 ) dx 2 x0 a = x0 x0 Z x1 Z x − x1 x − x0 1 x1 00 = f (x0) + f (x1) dx + f (ξ)(x − x0 )(x − x1) dx x0 − x 1 x1 − x 0 2 x0 x0 x 1 Z x1 (x − x1 )2 (x − x0 )2 1 00 = + f (ξ) (x − x0 )(x − x1 ) dx f (x0) + f (x1 ) 2(x0 − x1 ) 2(x1 − x0 ) 2 x0 x0 h3 (x0 − x1 )2 (x1 − x0 )2 1 = − f (x0 ) + f (x1) + f 00 (ξ) − 2(x0 − x1) 2(x1 − x0 ) 2 6 i h 3 h h = f (x0 ) + f (x1 ) − f 00 (ξ). 2 12 Thus, the Trapezoidal rule is Z b i h3 i hh b − ah f (x) dx = f (a) + f (b) − f 00 (ξ) ≈ f (a) + f (b) . 2 12 2 a Since the error term for the Trapezoidal rule involves f 00, the rule gives the exact result when applied to any function whose second derivative is identically zero. That is, the Trapezoidal rule gives the exact result for polynomials of degree up to or equal to one. 2 Composite Trapezoidal Rule We define h = b−a = xj − xj−1 . n Z b = xn n Z xj n h i X X h h3 00 f (x) dx = f (x) dx = f (xj−1 ) + f (xj ) − f (ξj ) 2 12 a = x0 xj−1 = j=1 n X hh = j=1 n X hh j=1 j=1 2 2 i f (xj−1 ) + f (xj ) n − h3 X 00 f (ξj ) 12 j=1 i f (xj−1 ) + f (xj ) − h2 12 (b − a)f 00(ξ). (since nh = b − a) Thus, the Composite Trapezoidal rule is Z b n i X xj − xj−1 h h2 f (x) dx = (b − a)f 00(ξ). f (xj−1 ) + f (xj ) − 2 12 a j=1 1 3 Simpson’s Rule Simpson’s rule can be derived by integrating the second Lagrange polynomial. However, this derivation gives only an O(h4) error term involving f (3). To get a better error term, we use Taylor polynomial to derive the Simpson’s rule. b−a Let x0 = a, x2 = b, and x1 = a+b 2 = a + 2 = a + h. That is, x1 − x0 = h and x2 − x1 = h. Z b = x2 Z x2 f 00 (x1) f (x1) + f 0 (x1)(x − x1 ) + f (x) dx = (x − x1 )2 2 a = x0 x0 f 000(x1) f (4)(ξ) 3 4 + (x − x1) + (x − x1) dx 6 24 f 0 (x1 ) f 00 (x1) = f (x1)x + (x − x1 )2 + (x − x1 )3 2 6 x 2 f 000(x1) f (4)(ξ) 4 5 + (x − x1) + (x − x1) 24 120 x0 i f 00(x ) h i f 0 (x1) h 1 = f (x1)(x2 − x0 ) + (x2 − x1 )2 − (x0 − x1)2 + (x2 − x1 )3 − (x0 − x1 )3 2 6 i i h (4) f 000(x1) h f (ξ) + (x2 − x1 )4 − (x0 − x1)4 + (x2 − x1 )5 − (x0 − x1)5 24 120 i f 00(x ) h i f 0 (x1 ) h 2 1 = 2hf (x1) + h − h2 + h 3 + h3 2 6 i i (4)(ξ) h f 000(x1) h 4 f + h − h4 + h 5 + h5 24 120 00 f (x1) f (4)(ξ) = 2hf (x1) + h3 + h5 60 3 3 h f (x0 ) − 2f (x1) + f (x2) h2 (4) h5 (4) = 2hf (x1) + − (ξ) + f f (ξ) 3 h2 12 60 i h5 hh = f (x0 ) + 4f (x1) + f (x2) − f (4)(ξ). 3 90 Thus, the Simpson’s rule is Z b f (x) dx = a 4 i h5 a + b i hh b − ah f (x0) + 4f (x1 ) + f (x2) − f (4)(ξ) ≈ f (a) + 4f + f (b) . 3 90 6 2 Composite Simpson’s Rule In order to obtain the formula for the Composite Simpson’s rule that agrees with professor’s formula, we need to make the change of notation. To avoid confusion, we just list the formula without its derivation. The Composite Simpson’s rule is Z b f (x) dx ≈ a n x i X xj − xj−1 h j−1 + xj f (xj−1 ) + 4f + f (xj ) . 6 2 j=1 2