An example from the last lecture Find the value of the three integrals Z 3 Z 2 2x 2x dx dx 2 2 −2 x − 1 −2 x − 1 Z 2 3 2x dx. −1 x2 A. 0, ln(8/3), ln(8/3) B. 0, ∞, ln(8/3) C. ∞, ln(8/3), ln(8/3) D. ∞, ∞, ln(8/3) Math 105 (Section 204) Numerical integration 2011W T2 1/6 Numerical integration Often a definite integral cannot be computed exactly, and its value has to be estimated with acceptable accuracy. Math 105 (Section 204) Numerical integration 2011W T2 2/6 Numerical integration Often a definite integral cannot be computed exactly, and its value has to be estimated with acceptable accuracy. Simpson’s rule If f is defined and integrable on [a, b], the Simpson’s rule approximation based on n equally spaced intervals is Z b f (x) dx ≈ Sn = a ∆x h f (x0 ) + 4f (x1 ) + 2f (x2 ) + 4f (x3 ) · · · + 3 i · · · + 4f (xn−1 ) + f (xn ) , where n is an even integer, ∆x = (b − a)/n, and xk = a + k∆x, k = 0, 1, 2, · · · , n. Math 105 (Section 204) Numerical integration 2011W T2 2/6 Where does the formula come from? Find the equation of the parabola y = px 2 + qx + r passing through the points (0, 0), (1, a) and (2, b). A. y = −a + b 2 x 2 + 2a − b 2 x B. y = ax 2 + bx C. y = bx 2 + ax D. y = 2a − b2 x 2 + −a + b2 x Math 105 (Section 204) Numerical integration 2011W T2 3/6 Where does the formula come from? Find the equation of the parabola y = px 2 + qx + r passing through the points (0, 0), (1, a) and (2, b). A. y = −a + b 2 x 2 + 2a − b 2 x B. y = ax 2 + bx C. y = bx 2 + ax D. y = 2a − b2 x 2 + −a + b2 x Use the correct answer above to find the area under the parabola between x = 0 and x = 2. Compare with the Simpson’s rule approximation. They are equal! Math 105 (Section 204) Numerical integration 2011W T2 3/6 Interpretation of Simpson’s rule Given a function f on an interval [a, b], consider a partition of [a, b] into n equal subintervals a = x0 < x1 < x2 < · · · < xn = b, and set Pj = (xj , f (xj )), j = 0, 1, · · · , n. Now approximate f by piecewise parabolas. Namely for each of the following triple of points (P0 , P1 , P2 ), (P2 , P3 , P4 ), (P4 , P5 , P6 ), · · · , (Pn−2 , Pn−1 , Pn ), fit a parabola through that set, as in the previous example. In Simpson’s rule, we approximate the area under f between [a, b] by the area under this piecewise parabolic curve. Math 105 (Section 204) Numerical integration 2011W T2 4/6 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 5/6 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 6/6