# Calculus 141, section 8.

6 The Trapezoidal Rule & Simpson’s Rule
notes by Tim Pilachowski Back in Math 140, section 5.1, you did Riemann sums. The interval a ≤ x ≤ b was split up into n subintervals, b−a = ∆ x . Then a series of rectangles was drawn, each with a width of ∆x and a called partitions, of width = n height of y = f(x). In section 8.6 we’re only going to consider the rectangles whose height is in the middle of the interval—the Midpoint Rule: Area under the curve ≅ f ( x1 ) ∗ ∆ x + f ( x 2 ) ∗ ∆ x + f ( x3 ) ∗ ∆ x + K f ( x n ) ∗ ∆ x b−a = ∗ [ f ( x1 ) + f ( x 2 ) + f ( x3 ) + K f ( x n )] n This formula (a Riemann sum) provides an approximation to the area under the curve for functions that are nonnegative and continuous. Example A, Midpoint Rule: Approximate the area under the curve y = x on the interval 2 ≤ x ≤ 4 using n = 5 subintervals.

Recalling that “area under the curve from a to b” =

b ∫a f (x ) dx , the Midpoint Rule can be used to approximate a

definite integral. Next, however, instead of rectangles, we’re going to create a series of trapezoids and calculate areas. Each trapezoid will still have a width of ∆x, but will also have two heights—one to each side, left and ∆x right, f ( xk −1 ) & f ( xk ) . The formula for the area of a trapezoid is [ f ( xk −1 ) + f ( xk )] ∗ . 2

Example A, Trapezoidal Rule: Approximate the area under the curve y = x on the interval 2 ≤ x ≤ 4 using n = 5 subintervals. That is, approximate the definite integral

∫2

4

x dx by the Trapezoidal Rule.

Simpson’s Rule: Approximate the area under the curve y = x on the interval 2 ≤ x ≤ 4 using 5 subintervals. x dx x = ∫2 ∫2 ⎟ ⎟ 3⎜ 2 3⎜ 3 ⎠ ⎝ ⎠ ⎝ 2 3⎞ The exact value for the area under the curve y = x on the interval 2 ≤ x ≤ 4 is ⎛ ⎜ 8 − 2 ⎟ which is 3⎝ ⎠ approximately 3.We can take this example and generalize into a Trapezoidal Rule for n subintervals: b ∆x ∆x ∆x ∆x ∆x ∆x ∫ a f (x ) dx ≅ f (x0 ) ∗ 2 + 2 f (x1 ) ∗ 2 + 2 f (x2 ) ∗ 2 + 2 f (x3 ) ∗ 2 + K + 2 f (xn −1 ) ∗ 2 + f (xn ) ∗ 2 ≅ b − a ∗ [ f ( x0 ) + 2 f ( x1 ) + 2 f ( x 2 ) + 2 f ( x3 ) + K + 2 f (x n −1 ) + f ( x n )] 2n Example A.44771525. Example A. the other is a bit low (our Trapezoidal Rule by about 0. That is.000688768). were each off by a bit. ∫2 4 x dx by Simpson’s Rule. where KT is an upper bound value for f ′′ (x ) for a ≤ x ≤ b. Each of the first two approximation methods.00137879). integration: ∫2 4 4 x dx . approximate the definite integral 2 ∗ 3. which can be found by inserting the formulae for Midpoint and Trapezoidal Rules into 2 M3+T .448403926 + 3. as is usually the case with functions of the type we’ll be seeing.447714771 3 Simpson’s Rule got us to within 5 decimal places. Trapezoidal Rule error: Find a value for n that guarantees an error of no more than 10–5 in the approximation by the Trapezoidal Rule of ∫2 4 x dx . 3 4 3 ⎞ 3 ⎞ ⎛ ⎛ 3 4 1 2 dx = 2 x 2 = 2 ⎜ 4 2 − 2 2 ⎟ = 2 ⎜ 8 − 2 2 ⎟ . Midpoint Rule and Trapezoidal Rule.44633646 ≅ 3. Simpson’s Rule combines this notion into a formula which weights the two according to their relative errors: b 2M + T ∫a f (x ) dx ≅ 3 . The Trapezoidal Rule estimate was a little bit low. while one of them is a bit high (our Midpoint Rule by about 0. Also note that. Example A. There is a comprehensive version of Simpson’s Rule. b − a ∗ [ f (x ) + 4 f (x ) + 2 f (x ) + 4 f (x ) + K + 2 f (x 0 1 2 3 n − 2 ) + 4 f ( x n −1 ) + f ( x n )] 3n . ∫2 4 x dx ≅ It is unnecessary to calculate both Midpoint and Trapezoidal Rules before calculating Simpson’s Rule. The error incurred by the Trapezoidal Rule to approximate b KT 3 T ∫a f (x ) dx satisfies E n ≤ 12n 2 (b − a ) .

Simpson’s Rule is a useful formula to know. and times 2 again to get a common denominator with the Trapezoidal Rule >> .5 x7 2. 4] the upper bound of the second derivative is f (4 ) (2) = 7 128 2 16 2 f ′ (x ) = S En ≤ 1 − 12 . Example B: Approximate x0 1 ∫1 3 e x dx using Simpson’s Rule for n = 8. Also.2 ⇒ n = 7 . 2 2 b KS 5 S ∫a f (x ) dx satisfies En ≤ 180n 4 (b − a ) . n must be an even number.08 . then combining the two. the beauty of Simpson’s Rule is that it applies to all continuous functions.52 ⎞ + 4 ⎛ e 2. approximation by the Simpson’s Rule of f (x ) = x 1 2. On the interval [2. Quick side note: I have given an explanation of Simpson’s Rule based on a combination of Midpoint and Trapezoidal Rules.252 ⎞ e + 4⎛ ⎜e ⎟ + 2⎜e ⎟ ⎜ ⎟ ⎜ ⎟ ⎜ ⎟ ⎜ ⎟ ⎜ ⎟ ⎢ ⎥ 3 (8) ⎣ ⎠ ⎝ ⎠ ⎝ ⎠ ⎝ ⎠ ⎝ ⎠ ⎝ ⎠ ⎝ ⎠ ⎝ ⎦ which is approximately 1475. while the explanations used strictly non-negative functions. e 3 = e 9 ≅ 8103.43 makes sense.752 ⎞ + e 32 ⎤ 1. since it is more efficient than finding Midpoint Rule and Trapezoidal Rule estimates first. f (3) ( x ) = 15 − 7 2 15 =− x 16 16 x 7 15 15 ≤ = KS .429234. Also.75 x8 3 2 x= x1 1.25 x6 2. Are they the same mathematically? Yes. the comprehensive formula is more accurate.752 ⎞ + 2 ⎛ e 22 ⎞ + 4 ⎛ e 2.] Side note: Why do the “Midpoint Rule” terms have a coefficient of 4? During the substitution into 2 M +T 3 and subsequent simplification process these terms are multiplied << times 2 in the formula.52 ⎞ + 4 ⎛ e1. [Note that for Simpson’s Rule. successive values for xk are alternately boundaries of subintervals (from Trapezoidal Rule—even subscripts) and midpoints of subintervals (from Midpoint Rule—odd subscripts).252 ⎞ + 2 ⎛ e 2. since rounding errors introduced in the Midpoint and Trapezoidal Rules get compounded. x 2 1 −3 f ′′ ( x ) = − x 2 . where KS Example A Simpson’s Rule error: Find a value for n that guarantees an error of no more than 10–5 in the ∫2 4 x dx . 4 3 − 52 . Note the very steep slope of the function y = e x when x > 1. The mathematics would be based on finding the equation of a suitable parabola given three points: two endpoints from the Trapezoidal Rule and the midpoint from the Midpoint Rule. so an area under the curve of 1475. The explanation given by the text is based on approximation using parabolas. x2 1. 720 2 ( ) . The error incurred by the Simpson’s Rule to approximate is an upper bound value for f (4 ) ( x ) for a ≤ x ≤ b.75 x4 2 x5 2. At x = 3. x 8 f (4 ) ( x ) = − (128 2 )(180n 4 ) 15 (4 − 2)5 = 15 720n 4 2 15 10 5 Choose n so that 15 720n 4 2 ≤ 10 − 5 ⇒ 720 2 ( ) ≤ n4 15 10 5 ⇒ n≥ 4 ≅ 6 .In this schema for explaining Simpson’s Rule. whether or not they are non-negative.5 x3 1.25 3 −1 ⎡ 1 ⎛ 1. but there isn’t time to go into the details.

75 11 = 1.25 9 x4 3.5 3 x3 2.25 5 x2 2.11666667 2 (4) ⎣ 3 5 3⎦ ⎝ 3⎠ ⎝ 2 ⎠ ⎝ 5 ⎠ 3⎦ 4 ⎣ Simpson’s Rule. Midpoint Rule with 4 subintervals. this integral may look like one could use integration by parts.5 5 x4 4 4 3 4−2 ⎡ 14 4 ⎤ ⎛ 5⎞ ⎛ 3 ⎞ ⎛ 7 ⎞ 4 ⎤ 1 ⎡ 10 ∗ ⎢2 + 2 ⎜ ⎟ + 2 ⎜ ⎟ + 2 ⎜ ⎟ + ⎥ = ∗ ⎢2 + + 3 + + ⎥ ≅ 3. (There are other methods of integration we won’t be using in this class.75 7 x3 3. using Midpoint Rule (4 subintervals).5 7 = 2.75 2. values of xk include both endpoints and midpoints from above.75 11 4 − 2 ⎡ 9 11 13 15 ⎤ 1 ⎡ 9 11 13 15 ⎤ ∗⎢ + + + ⎥ = ∗ + + + ⎥ 4 2 ⎢ ⎣ 5 7 9 11 ⎦ ⎣ 5 7 9 11 ⎦ ≅ 3.25 3. n = 8 x f ( x) x0 2 2 x1 2.Example C: Approximate ∫2 4 x dx .5 3.75 3.75 2.25 2.5 3 x2 3 3 2 x3 3.5 5 x7 3.25 3. Trapezoidal Rule (4 subintervals) x −1 and Simpson’s Rule (n = 8).08975469 Trapezoidal Rule with 4 subintervals.75 7 x4 3 3 2 x5 3.09872535 12 ⎣ 5 3 7 9 5 11 3⎦ By the way. values of xk are endpoints of subintervals x f ( x) x0 2 2 x1 2.) .5 5 = 1. it’s not—no matter how you try to define u and dv.5 7 = 2.25 9 x6 3.75 11 = 1.75 11 x8 4 4 3 9 ⎞ ⎛ 5 ⎞ ⎛ 11 ⎞ ⎛ 3 ⎞ ⎛ 13 ⎞ ⎛ 7 ⎞ ⎛ 15 ⎞ 4 ⎤ 4 − 2 ∗ ⎡2 + 4⎛ ⎜ ⎟ + 2⎜ ⎟ + 4⎜ ⎟ + 2⎜ ⎟ + 4⎜ ⎟ + 2⎜ ⎟ + 4⎜ ⎟ + ⎥ ⎢ 3 (8) ⎣ ⎝ 5 ⎠ ⎝ 3 ⎠ ⎝ 7 ⎠ ⎝ 2 ⎠ ⎝ 9 ⎠ ⎝ 5 ⎠ ⎝ 11 ⎠ 3 ⎦ 1 ⎡ 36 10 44 52 14 60 4⎤ = ∗ ⎢2 + + + + 3 + + + + ⎥ ≅ 3.25 5 x2 2.75 15 = 2. However.25 13 = 2.25 9 = 1.25 2.75 3.5 3.5 2. you get an even messier integral to deal with. values of xk are midpoints of subintervals x f(x) x1 2.75 15 = 2.5 2.5 5 = 1.25 13 = 2.25 9 = 1.