3 The composite trapezium rule

The general idea here is to split the interval [ a , b ] into a sequence of N smaller subintervals of equal width h = ( b a ) N . Then we apply the simple trapezium rule to each of the subintervals.

Figure 7 below shows the case where N = 2 (and h = 1 2 ( b a ) ). To simplify notation later on we let f 0 = f ( a ) , f 1 = f ( a + h ) and f 2 = f ( a + 2 h ) = f ( b ) .

Figure 7

No alt text was set. Please request alt text from the person who provided you with this resource.

Applying the simple trapezium rule to each subinterval we get

a b f ( x ) d x area of first trapezium + area of second trapezium = 1 2 h ( f 0 + f 1 ) + 1 2 h ( f 1 + f 2 ) = 1 2 h f 0 + 2 f 1 + f 2

where we remember that the width of each of the subintervals is h , rather than the b a we had in the simple trapezium rule.

The next improvement will come from taking N = 3 subintervals (Figure 8). Here h = 1 3 ( b a ) is smaller than in Figure 7 above and we denote f 0 = f ( a ) , f 1 = f ( a + h ) , f 2 = f ( a + 2 h ) and f 3 = f ( a + 3 h ) = f ( b ) . (Notice that f 1 and f 2 mean something different from what they did in the N = 2 case.)

Figure 8

No alt text was set. Please request alt text from the person who provided you with this resource.

As Figure 8 shows, the approximation is getting closer to the grey shaded area and in this case we have

a b f ( x ) d x 1 2 h ( f 0 + f 1 ) + 1 2 h ( f 1 + f 2 ) + 1 2 h ( f 2 + f 3 ) = 1 2 h f 0 + 2 f 1 + f 2 + f 3 .

The pattern is probably becoming clear by now, but here is one more improvement. In Figure 9 N = 4 , h = 1 4 ( b a ) and we denote f 0 = f ( a ) , f 1 = f ( a + h ) , f 2 = f ( a + 2 h ) , f 3 = f ( a + 3 h ) and f 4 = f ( a + 4 h ) = f ( b ) .

Figure 9

No alt text was set. Please request alt text from the person who provided you with this resource.

This leads to

a b f ( x ) d x 1 2 h ( f 0 + f 1 ) + 1 2 h ( f 1 + f 2 ) + 1 2 h ( f 2 + f 3 ) + + 1 2 h ( f 3 + f 4 ) = 1 2 h f 0 + 2 f 1 + f 2 + f 3 + f 4 .

We generalise this idea into the following Key Point.

Key Point 7

Composite Trapezium Rule

The composite trapezium rule for approximating a b f ( x ) d x is carried out as follows:

  1. Choose N , the number of subintervals,
  2. a b f ( x ) d x 1 2 h f 0 + 2 { f 1 + f 2 + + f N 1 } + f N ,



    where h = b a N , f 0 = f ( a ) , f 1 = f ( a + h ) , , f n = f ( a + n h ) , , and   f N = f ( a + N h ) = f ( b ) .
Example 12

Using 4 subintervals in the composite trapezium rule, and working to 6 decimal

 places, approximate

0 2 cosh ( x ) d x

Solution

In this case h = ( 2 0 ) 4 = 0.5 .

We require cosh ( x ) evaluated at five x -values and the results are tabulated below to 6 d.p.

x n f n = cosh ( x n ) ̲ ̲ 0 1.000000 0.5 1.127626 1 1.543081 1.5 2.352410 2 3.762196

It follows that

0 2 cosh ( x ) d x 1 2 h f 0 + f 4 + 2 { f 1 + f 2 + f 3 } = 1 2 ( 0.5 ) 1 + 3.762196 + 2 { 1.127626 + 1.543081 + 2.35241 } = 3.452107
Task!

Using 4 subintervals in the composite trapezium rule approximate

1 2 ln ( x ) d x

In this case h = ( 2 1 ) 4 = 0.25 .

We require ln ( x ) evaluated at five x -values and the results are tabulated below t0 6 d.p.

x n f n = ln ( x n ) ̲ ̲ 1 0.000000 1.25 0.223144 1.5 0.405465 1.75 0.559616 2 0.693147

It follows that

1 2 ln ( x ) d x 1 2 h f 0 + f 4 + 2 { f 1 + f 2 + f 3 } = 1 2 ( 0.25 ) 0 + 0.693147 + 2 { 0.223144 + 0.405465 + 0.559616 } = 0.383700

3.1 How good is the composite trapezium rule?

We can work out an upper bound on the error incurred by the composite trapezium method. Fortunately, all we have to do here is apply the method for the error in the simple rule over and over again. Let e T N denote the error in the composite trapezium rule with N subintervals. Then

e T N max 1st subinterval f ( x ) h 3 12 + max 2nd subinterval f ( x ) h 3 12 + + max last subinterval f ( x ) h 3 12 = h 3 12 max 1st subinterval f ( x ) + max 2nd subinterval f ( x ) + + max last subinterval f ( x ) .   N  terms

This is all very well as a piece of theory, but it is awkward to use in practice. The process of working out the maximum value of f separately in each subinterval is very time-consuming. We can obtain a more user-friendly, if less accurate, error bound by replacing each term in the last bracket above with the biggest one. Hence we obtain

e T N h 3 12 N max a x b f ( x )

This upper bound can be rewritten by recalling that N h = b a , and we now summarise the result in a Key Point.

Key Point 8

Error in the Composite Trapezium Rule

The error, e T N , in the N -subinterval composite trapezium approximation to a b f ( x ) d x is bounded above by

max a x b f ( x ) ( b a ) h 2 12

Note: the special case when N = 1 is the simple trapezium rule, in which case b a = h (refer to Key Point 6 to compare).

The formula in Key Point 8 can be used to decide how many subintervals to use to guarantee a specific accuracy.

Example 13

The function f is known to have a second derivative with the property that

f ( x ) < 12

for x between 0 and 4.

Using the error bound given in Key Point 8 determine how many subintervals are required so that the composite trapezium rule used to approximate

0 4 f ( x ) d x

can be guaranteed to be in error by less than 1 2 × 1 0 3 .

Solution

We require that

12 × ( b a ) h 2 12 < 0.0005

that is

4 h 2 < 0 . 0005 .

This implies that h 2 < 0.000125 and therefore h < 0.0111803 .

Now N = ( b a ) h = 4 h and it follows that

N > 357.7708

Clearly, N must be a whole number and we conclude that the smallest number of subintervals which guarantees an error smaller than 0.0005 is N = 358 .

It is worth remembering that the error bound we are using here is a pessimistic one. We effectively use the same (worst case) value for f ( x ) all the way through the integration interval. Odds are that fewer subintervals will give the required accuracy, but the value for N we found here will guarantee a good enough approximation.

Next are two Tasks for you to try.

Task!

The function f is known to have a second derivative with the property that

f ( x ) < 14

for x between 1 and 4.

Using the error bound given in Key Point 8 determine how many subintervals are required so that the composite trapezium rule used to approximate

1 4 f ( x ) d x

can be guaranteed to have an error less than 0.0001.

We require that

14 × ( b a ) h 2 12 < 0.0001

that is

70 h 2 12 < 0.0001

This implies that h 2 < 0.00001714 and therefore h < 0.0041404 .

Now N = ( b a ) h = 5 h and it follows that

N > 1207.6147

Clearly, N must be a whole number and we conclude that the smallest number of subintervals which guarantees an error smaller than 0.00001 is N = 1208 .

Task!

It is given that the function e x 2 2 has a second derivative that is never greater than 1 in absolute value.

  1. Use this fact to determine how many subintervals are required for the composite trapezium method to deliver an approximation to

    0 1 1 2 π e x 2 2 d x

    that is guaranteed to have an error less than 1 2 × 1 0 2 .

  2. Find an approximation to the integral that is in error by less than 1 2 × 1 0 2 .

We require that 1 2 π ( b a ) h 2 12 < 0.005 . This means that h 2 < 0.150398 and therefore, since N = 1 h , it is necessary for N = 3 for the error bound to be less than ± 1 2 × 1 0 2 .

To carry out the composite trapezium rule, with h = 1 3 we need to evaluate f ( x ) = 1 2 π e x 2 2 at x = 0 , h , 2 h , 1 . This evaluation gives

f ( 0 ) = f 0 = 0.39894 , f ( h ) = f 1 = 0.37738 , f ( 2 h ) = f 2 = 0.31945

and f ( 1 ) = f 3 = 0.24197 ,

all to 5 decimal places. It follows that

0 1 1 2 π e x 2 2 d x 1 2 h ( f 0 + f 3 + 2 { f 1 + f 2 } ) = 0.33910

We know from part 1. that this approximation is in error by less than 1 2 × 1 0 2 .

Example 14

Determine the minimum number of steps needed to guarantee an error not

exceeding ± 0.001 , when evaluating

0 1 cosh ( x 2 ) d x

using the trapezium rule.

Solution

f ( x ) = cosh ( x 2 ) f ( x ) = 2 x sinh ( x 2 ) f ( x ) = 2 sinh ( x 2 ) + 4 x 2 cosh ( x 2 )

Using the error formula in Key Point 8

E = 1 12 h 2 { 2 sinh ( x 2 ) + 4 x 2 cosh ( x 2 ) } x [ 0 , 1 ]

E max occurs when x = 1

0.001 > h 2 12 { 2 sinh ( 1 ) + 4 cosh ( 1 ) } h 2 < 0.012 { ( 2 sinh ( 1 ) + 4 cosh ( 1 ) ) } h 2 < 0.001408 h < 0.037523 n 26.651 n = 27 needed
Task!

Determine the minimum of strips, n , needed to evaluate by the trapezium rule:

0 π 4 { 3 x 2 1.5 sin ( 2 x ) } d x

such that the error is guaranteed not to exceed ± 0.005 .

f ( x ) = 3 x 2 1.5 sin ( 2 x ) f ( x ) = 6 + 6 sin ( 2 x )

Error will be maximum at  x = π 4 so that sin ( 2 x ) = 1

E = ( b a ) 12 h 2 f ( 2 ) ( x ) x [ 0 , π 4 ]

E = π 48 h 2 6 { 1 + sin ( 2 x ) } , x [ 0 , π 4 ]

E max = π 48 h 2 ( 12 ) = π h 2 4

We need π h 2 4 < 0.005 h 2 < 0.02 π h < 0.07979

Now n h = ( b a ) = π 4 so n = π 4 h

We need n > π 4 × 0.07979 = 9.844 so n = 10 required