Simpson’s rule: Summary of the last lecture Sometimes definite integrals cannot be exactly evaluated using known analytical techniques, and have to be estimated. An example is Z 4 2 e −x dx. 0 Math 105 (Section 204) Numerical integration 2011W T2 1/8 Simpson’s rule: Summary (ctd) Simpson’s rule is a strategy for estimating a definite integral of the form Z b f (x) dx a using the approximation formula: Sn = n ∆x X aj f (xj ), 3 j=0 where n is an even integer, ∆x = (b − a)/n and the coefficients aj satisfy ( 4 if 1 < j < n, j odd, a0 = an = 1, aj = 2 if 1 < j < n, j even. Math 105 (Section 204) Numerical integration 2011W T2 2/8 Simpson’s rule: Summary (ctd) Simpson’s rule is a strategy for estimating a definite integral of the form Z b f (x) dx a using the approximation formula: Sn = n ∆x X aj f (xj ), 3 j=0 where n is an even integer, ∆x = (b − a)/n and the coefficients aj satisfy ( 4 if 1 < j < n, j odd, a0 = an = 1, aj = 2 if 1 < j < n, j even. What is the Simpson’s rule approximation for the example in the first slide? Math 105 (Section 204) Numerical integration 2011W T2 2/8 Interpetation of Simpson’s rule Simpson’s rule is exact, i.e., gives the correct answer, for computing areas under quadratic curves. In other words, the value of any integral of the form Z b 2 px + qx + r dx a is the same as its Simpson’s rule approximation. Let’s check this! Math 105 (Section 204) Numerical integration 2011W T2 3/8 Explanation of the Simpson’s rule formula Now fix a general (not necessarily quadratic) curve y = f (x), an interval [a, b], and a partition a = x0 < x1 < x2 < · · · < xn = b, where n is an even integer. Step 1. Replace the curve y = f (x) on the first subinterval [x0 , x2 ] by a parabola C1 that agrees with f at three points, namely passes through (x0 , f (x0 )), (x1 , f (x1 )) and (x2 , f (x2 )). Then Z x2 f (x) dx ≈ A1 x0 = area under C1 between [x0 , x2 ] ∆x [f (x0 ) + 4f (x1 ) + f (x2 )] . = 3 Math 105 (Section 204) Numerical integration 2011W T2 4/8 Explanation of the Simpson’s rule formula Step 2. Repeat the same step as above but now on the interval [x2 , x4 ]. Let C2 be the parabola that passes through (x2 , f (x2 )), (x3 , f (x3 )) and (x4 , f (x4 )). Z x4 f (x) dx ≈ A2 x2 = area under C2 between [x2 , x4 ] ∆x = [f (x2 ) + 4f (x3 ) + f (x4 )] . 3 ··· ··· ··· Continue until you run out of points, in n/2 steps. Math 105 (Section 204) Numerical integration 2011W T2 5/8 Explanation of the Simpson’s rule formula Approximate area Simpson’s rule says that an estimate for the actual area under the curve y = f (x) on [a, b] is the sum of the area of the approximating parabolas; namely, Z b f (x) dx ≈ Sn = A1 + A2 + · · · a = ∆x h f (x0 ) + 4f (x1 ) + 2f (x2 ) + 4f (x3 ) + · · · + 3 i 4f (xn−1 ) + f (xn ) . Math 105 (Section 204) Numerical integration 2011W T2 6/8 How good is the approximation? Error bound Assume that f (4) is continuous on the interval [a, b] and that K is a real number such that (4) f (x) ≤ K on [a, b]. Then the error in approximation satisfies the inequality Z b K (b − a) ES = f (x) dx − Sn ≤ (∆x)4 . 180 a Math 105 (Section 204) Numerical integration 2011W T2 7/8 Example You program your calculator to compute definite integrals using Simpson’s rule with n = 6. If you evaluate Z 6 e −3x dx 0 using your calculator, find the maximum amount by which your result would differ from the correct answer. A. 1 B. 81/180 C. 1/180 D. 10/27 Math 105 (Section 204) Numerical integration 2011W T2 8/8