Section 6.5 Approximate Integration 2010 Kiryl Tsishchanka Approximate Integration MIDPOINT RULE: Zb f (x)dx ≈ Mn = ∆x[f (x1 ) + f (x2 ) + . . . + f (xn )] a where ∆x = b−a n 1 and xi = (xi−1 + xi ) = midpoint of [xi−1 , xi ]. 2 TRAPEZOIDAL RULE: Zb a f (x)dx ≈ Tn = ∆x [f (x0 ) + 2f (x1 ) + 2f (x2 ) + . . . + 2f (xn−1 ) + f (xn )] 2 where ∆x = and xi = a + i∆x. 1 b−a n Section 6.5 Approximate Integration 2010 Kiryl Tsishchanka EXAMPLE: Use (a) the Trapezoidal Rule and (b) the Midpoint Rule with n = 5 to approximate the integral Z2 1 dx x 1 Solution: (a) With n = 5, a = 1, and b = 2, we have ∆x = (2 − 1)/5 = 0.2, and so the Trapezoidal Rule gives Z2 ∆x 1 dx ≈ T5 = [f (1) + 2f (1.2) + 2f (1.4) + 2f (1.6) + 2f (1.8) + f (2)] x 2 1 0.2 1 2 2 2 2 1 ≈ 0.695635 = + + + + + 2 1 1.2 1.4 1.6 1.8 2 (b) The midpoints of the five subintervals are 1.1, 1.3, 1.5, 1.7, and 1.9, so the Midpoint Rule gives Z2 1 dx ≈ M5 = ∆x[f (1.1) + f (1.3) + f (1.5) + f (1.7) + f (1.9)] x 1 1 1 1 1 1 1 ≈ 0.691908 = + + + + 5 1.1 1.3 1.5 1.7 1.9 REMARK: Note that Z2 1 2 1 dx = ln x = ln 2 ≈ 0.693147 1 x therefore the errors in the Trapezoidal and Midpoint Rule approximations for n = 5 are ET ≈ −0.002488 and EM ≈ 0.001239 We see that the size of the error in the Midpoint Rule is about half the size of the error in the Trapezoidal Rule. EXAMPLE: Use (a) the Trapezoidal Rule and (b) the Midpoint Rule with n = 10 to approximate the integral Z1 2 ex dx 0 2 Section 6.5 Approximate Integration 2010 Kiryl Tsishchanka EXAMPLE: Use (a) the Trapezoidal Rule and (b) the Midpoint Rule with n = 10 to approximate the integral Z1 2 ex dx 0 Solution: (a) With n = 10, a = 0, and b = 1, we have ∆x = (1 − 0)/10 = 0.1, and so the Trapezoidal Rule gives Z1 ∆x [f (0) + 2f (0.1) + 2f (0.2) + . . . + 2f (0.8) + 2f (0.9) + f (1)] 2 0 0.1 02 2 2 2 2 2 e + 2e0.1 + 2e0.2 + . . . + 2e0.8 + 2e0.9 + e1 ≈ 1.467174693 = 2 2 ex dx ≈ T10 = (b) The midpoints of the ten subintervals are 0.05, 0.15, 0.25, . . . , 0.85, 0.95, so the Midpoint Rule gives Z1 0 = 2 ex dx ≈ M10 = ∆x[f (0.05) + f (0.15) + f (0.25) + . . . + f (0.85) + f (0.95)] 1 0.052 2 2 2 2 e + e0.15 + e0.25 + . . . + e0.85 + e0.95 ≈ 1.460393091 10 REMARK: One can compute that Z1 2 ex dx ≈ 1.462651746 0 therefore the errors in the Trapezoidal and Midpoint Rule approximations for n = 10 are ET ≈ −0.004522947 and EM ≈ 0.002258655 We see that the size of the error in the Midpoint Rule is about half the size of the error in the Trapezoidal Rule. EXAMPLE: Use (a) the Trapezoidal Rule and (b) the Midpoint Rule with n = 10 to approximate the integral Z1 √ 1 + x3 dx 0 3 Section 6.5 Approximate Integration 2010 Kiryl Tsishchanka EXAMPLE: Use (a) the Trapezoidal Rule and (b) the Midpoint Rule with n = 10 to approximate the integral Z1 √ 1 + x3 dx 0 Solution: (a) With n = 10, a = 0, and b = 1, we have ∆x = (1 − 0)/10 = 0.1, and so the Trapezoidal Rule gives Z1 √ ∆x [f (0) + 2f (0.1) + 2f (0.2) + . . . + 2f (0.8) + 2f (0.9) + f (1)] 2 0 √ √ √ √ √ 0.1 √ 1 + 03 + 2 1 + 0.13 + 2 1 + 0.23 + . . . + 2 1 + 0.83 + 2 1 + 0.93 + 1 + 13 = 2 1 + x3 dx ≈ T10 = ≈ 1.112332391 (b) The midpoints of the ten subintervals are 0.05, 0.15, 0.25, . . . , 0.85, 0.95 so the Midpoint Rule gives Z1 √ 0 = 1 + x3 dx ≈ M10 = ∆x[f (0.05) + f (0.15) + f (0.25) + . . . + f (0.85) + f (0.95)] √ √ √ √ 1 √ 1 + 0.053 + 1 + 0.153 + 1 + 0.253 + . . . + 1 + 0.853 + 1 + 0.953 10 ≈ 1.111005559 REMARK: One can compute that Z1 √ 1 + x3 dx ≈ 1.111447979 0 therefore the errors in the Trapezoidal and Midpoint Rule approximations for n = 10 are ET ≈ −0.000884412 and EM ≈ 0.000442420 We see that the size of the error in the Midpoint Rule is about half the size of the error in the Trapezoidal Rule. ERROR BOUNDS: Suppose |f ′′ (x)| ≤ K for a ≤ x ≤ b. If ET and EM are the errors in the Trapezoidal and Midpoint Rules, then |ET | ≤ K(b − a)3 12n2 and |EM | ≤ K(b − a)3 24n2 EXAMPLE: Give upper bounds for the errors ET and EM involved in the approximation of Z2 1 dx with n = 5. x 1 4 Section 6.5 Approximate Integration 2010 Kiryl Tsishchanka EXAMPLE: Give upper bounds for the errors ET and EM involved in the approximation of Z2 1 dx with n = 5. x 1 Solution: Note that f ′ (x) = − Since 1 x2 and f ′′ (x) = 2 x3 2 is a decreasing function on [1, 2], we have x3 2 2 ′′ |f (x)| = 3 ≤ 3 = 2 x 1 Therefore, taking K = 2, a = 1, b = 2, and n = 5 in the above error estimates, we obtain |ET | ≤ 2(2 − 1)3 1 K(b − a)3 = = ≈ 0.0067 2 2 12n 12(5) 150 |EM | ≤ K(b − a)3 2(2 − 1)3 1 = = ≈ 0.0033 2 2 24n 24(5) 300 and REMARK: Note that these error estimates are bigger than the actual errors 0.002488 and 0.001239. EXAMPLE: Give upper bounds for the errors ET and EM involved in the approximation of Z1 2 ex dx with n = 10. 0 Solution: Note that f ′ (x) = 2xex 2 2 2 and f ′′ (x) = 2ex + 4x2 ex 2 2 Since 2ex + 4x2 ex is an increasing function on [0, 1], we have 2 2 2 2 |f ′′ (x)| = 2ex + 4x2 ex ≤ 2e1 + 4(1)2 e1 = 6e Therefore, taking K = 6e, a = 0, b = 1, and n = 10 in the above error estimates, we obtain |ET | ≤ K(b − a)3 6e(1 − 0)3 e = = ≈ 0.01359140914 12n2 12(10)2 200 |EM | ≤ K(b − a)3 6e(1 − 0)3 e = = ≈ 0.006795704570 24n2 24(10)2 400 and REMARK: Note that these error estimates are bigger than the actual errors 0.004522947 and 0.002258655. EXAMPLE: Give upper bounds for the errors ET and EM involved in the approximation of Z1 √ 1 + x3 dx with n = 10. 0 5 Section 6.5 Approximate Integration 2010 Kiryl Tsishchanka EXAMPLE: Give upper bounds for the errors ET and EM involved in the approximation of Z1 √ 1 + x3 dx with n = 10. 0 Solution: Note that (see the Appendix) 3x2 f ′ (x) = √ 2 1 + x3 and f ′′ (x) = 3x(x3 + 4) 4(1 + x3 )3/2 We now find increasing/decreasing intervals of f ′′ (x). Here is the graph of f ′′ (x): To find a point of a local maximum, we note that (see the Appendix) f ′′′ (x) = − 3(x6 + 20x3 − 8) 8(1 + x3 )5/2 One can check that f ′′′ (x) = 0 on [0, 1] at x ≈ 0.7320508076 which is a root of x6 +20x3 −8 = 0. It is easy to show that this is a point of a local maximum of f ′′ (x). So, 3 3x(x3 + 4) 3x(x + 4) ′′ ≤ ≈ 1.467889825 |f (x)| = 4(1 + x3 )3/2 4(1 + x3 )3/2 x=0.7320508076... Therefore, taking K = 1.467889825, a = 0, b = 1, and n = 10 in the above error estimates, we obtain K(b − a)3 1.467889825(1 − 0)3 |ET | ≤ = ≈ 0.001223241521 12n2 12(10)2 and 1.467889825(1 − 0)3 K(b − a)3 = ≈ 0.0006116207604 |EM | ≤ 24n2 24(10)2 REMARK: Note that these error estimates are bigger than the actual errors 0.000884412 and 0.000442420. EXAMPLE: How large should we take n in order to guarantee that the Trapezoidal and MidZ2 1 dx are accurate to within 0.0001? point Rule approximations for x 1 6 Section 6.5 Approximate Integration 2010 Kiryl Tsishchanka EXAMPLE: How large should we take n in order to guarantee that the Trapezoidal and MidZ2 1 point Rule approximations for dx are accurate to within 0.0001? x 1 Solution: We saw in one of the previous examples that |f ′′(x)| ≤ 2 for 1 ≤ x ≤ 2, so we can take K = 2, a = 1, and b = 2 in K(b − a)3 K(b − a)3 and |E | ≤ M 12n2 24n2 Accuracy to within 0.0001 means that the size of the error should be less than 0.0001. Therefore, we choose n so that 2 · 13 < 0.0001 (Trapezoidal Rule) 12n2 Solving the inequality for n, we get 1 2 =⇒ n > √ ≈ 40.8 n2 > 12(0.0001) 0.0006 Thus n = 41 will ensure the desired accuracy. |ET | ≤ For the same accuracy with the Midpoint Rule we choose n so that 2 · 13 < 0.0001 24n2 =⇒ n> √ 1 ≈ 29 0.0012 SIMPSON’S RULE: Zb f (x)dx ≈ Sn = ∆x [f (x0 ) + 4f (x1 ) + 2f (x2 ) + 4f (x3 ) + . . . + 2f (xn−2 ) + 4f (xn−1 ) + f (xn )] 3 a where n is even and ∆x = b−a . n ERROR BOUND FOR SIMPSON’S RULE: Suppose that |f (4) (x)| ≤ K for a ≤ x ≤ b. If ES is the error involved in using Simpson’s Rule, then |ES | ≤ K(b − a)5 180n4 EXAMPLE: How large should we take n in order to guarantee that the Simpson’s Rule apZ2 proximation for x3 dx is accurate to within 0.0001? 0 7 Section 6.5 Approximate Integration 2010 Kiryl Tsishchanka EXAMPLE: How large should we take n in order to guarantee that the Simpson’s Rule apZ2 proximation for x3 dx is accurate to within 0.0001? 0 Solution: Note that f ′ (x) = 3x2 , f ′′ (x) = 6x, and f (4) (x) = 0 f ′′′ (x) = 6, Therefore, taking K = 0 in the above error estimate, we obtain K(b − a)5 0 · (b − a)5 = =0 180n4 180n4 Z2 This means that Simpson’s Rule gives the exact value of x3 dx with n = 2. In fact, |ES | ≤ 0 Z2 0 which is the same as 2 x4 24 x dx = = =4 4 0 4 3 1 3 [0 + 4 · 13 + 23 ] 3 REMARK: One can show that if f is a polynomial of degree 3 or lower, then Simpson’s Rule Zb gives the exact value of f (x)dx. a EXAMPLE: How large should we take n in order to guarantee that the Simpson’s Rule apZ2 1 dx is accurate to within 0.0001? proximation for x 1 Solution: If f (x) = 1/x, then f (4) (x) = 24/x5 . Since 24/x5 is a decreasing function on [1, 2], we have 24 24 (4) |f (x)| = 5 ≤ 5 = 24 x 1 Therefore, we can take K = 24, a = 1, and b = 2 in K(b − a)5 180n4 Accuracy to within 0.0001 means that the size of the error should be less than 0.0001. Therefore, we choose n so that 24 · 15 < 0.0001 180n4 Solving the inequality for n, we get 1 24 ≈ 6.04 =⇒ n > √ n4 > 4 180(0.0001) 0.00075 |ES | ≤ Thus n = 8 (n must be even) will ensure the desired accuracy. 8 Section 6.5 Approximate Integration 2010 Kiryl Tsishchanka Appendix EXAMPLE: Let f (x) = √ 1 + x3 . Find f ′ , f ′′ , and f ′′′ . Solution: Since f (x) = (1 + x3 )1/2 , we have 1 3x2 1 f ′ (x) = (1 + x3 )1/2−1 · (1 + x3 )′ = (1 + x3 )−1/2 · 3x2 = √ 2 2 2 1 + x3 ′′ f (x) = 3x2 2(1 + x3 )1/2 ′ 3 = 2 = x2 (1 + x3 )1/2 ′ 3 (x2 )′ (1 + x3 )1/2 − x2 [(1 + x3 )1/2 ]′ · 2 [(1 + x3 )1/2 ]2 3 1/2−1 3 1/2 21 · (1 + x3 )′ 3 2x(1 + x ) − x 2 (1 + x ) = · 2 1 + x3 3 1/2 21 2x(1 + x ) − x (1 + x3 )−1/2 · 3x2 3 2 = · 2 1 + x3 3 4 3 −1/2 3 1/2 3 2x(1 + x ) − 2 x (1 + x ) = · 2 1 + x3 3 4 3 −1/2 3 1/2 · 2(1 + x3 )1/2 2x(1 + x ) − x (1 + x ) 3 2 = · 2 (1 + x3 ) · 2(1 + x3 )1/2 3 4 3 −1/2 3 1/2 3 1/2 · 2(1 + x3 )1/2 3 2x(1 + x ) · 2(1 + x ) − 2 x (1 + x ) = · 2 2(1 + x3 )3/2 = 3 4x(1 + x3 ) − 3x4 · 2 2(1 + x3 )3/2 = 3 4x + 4x4 − 3x4 · 2 2(1 + x3 )3/2 = 3 4x + x4 · 2 2(1 + x3 )3/2 = 3 x(4 + x3 ) · 2 2(1 + x3 )3/2 3x(4 + x3 ) = 4(1 + x3 )3/2 9 Section 6.5 Approximate Integration 2010 Kiryl Tsishchanka ′ 3x(4 + x3 ) f (x) = 4(1 + x3 )3/2 ′ 3 x(4 + x3 ) = 4 (1 + x3 )3/2 ′′′ = 3 [x(4 + x3 )]′ (1 + x3 )3/2 − x(4 + x3 )[(1 + x3 )3/2 ]′ · 4 [(1 + x3 )3/2 ]2 3 3/2−1 ′ 3 3 ′ 3 3/2 3 3 · (1 + x3 )′ 3 [x (4 + x ) + x(4 + x ) ](1 + x ) − x(4 + x ) 2 (1 + x ) = · 4 (1 + x3 )3 3 2 3 3/2 3 3 [1 · (4 + x ) + x · 3x ](1 + x ) − x(4 + x ) (1 + x3 )1/2 · 3x2 3 2 = · 3 3 4 (1 + x ) 9 3 3 3 1/2 3 3 3 3/2 3 (4 + x + 3x )(1 + x ) − 2 x (4 + x )(1 + x ) = · 4 (1 + x3 )3 9 3 3 3 1/2 3 3 3/2 3 (4 + 4x )(1 + x ) − 2 x (4 + x )(1 + x ) = · 4 (1 + x3 )3 9 3 3 3 1/2 3 3 3/2 3 4(1 + x )(1 + x ) − 2 x (4 + x )(1 + x ) = · 4 (1 + x3 )3 9 3 3 5/2 x (4 + x3 )(1 + x3 )1/2 4(1 + x ) − 3 2 = · 4 (1 + x3 )3 9 3 3 3 1/2 3 5/2 · 2(1 + x3 )−1/2 4(1 + x ) − x (4 + x )(1 + x ) 3 2 = · 4 (1 + x3 )3 · 2(1 + x3 )−1/2 9 3 5/2 3 −1/2 − x3 (4 + x3 )(1 + x3 )1/2 · 2(1 + x3 )−1/2 3 4(1 + x ) · 2(1 + x ) 2 = · 4 2(1 + x3 )5/2 = 3 8(1 + 2x3 + x6 ) − 36x3 − 9x6 3 8(1 + x3 )2 − 9x3 (4 + x3 ) · = · 4 2(1 + x3 )5/2 4 2(1 + x3 )5/2 = 3 8 + 16x3 + 8x6 − 36x3 − 9x6 3 8 − 20x3 − x6 · = · 4 2(1 + x3 )5/2 4 2(1 + x3 )5/2 = 3(x6 + 20x3 − 8) 3(8 − 20x3 − x6 ) = − 8(1 + x3 )5/2 8(1 + x3 )5/2 10