4 Other methods for approximating integrals

Here we briefly describe other methods that you may have heard, or get to hear, about. In the end they all amount to the same sort of thing, that is we sample the integrand f at a few points in the integration interval and then take a weighted average of all these f values. All that is needed to implement any of these methods is the list of sampling points and the weight that should be attached to each evaluation. Lists of these points and weights can be found in many books on the subject.

4.1 Simpson’s rule

This is based on passing a quadratic through three equally spaced points, rather than passing a straight line through two points as we did for the simple trapezium rule. The composite Simpson’s rule is given in the following Key Point.

Key Point 9

Composite Simpson’s Rule

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

  1. Choose N , which must be an even number of subintervals,
  2. Calculate a b f ( x ) d x

    1 3 h f 0 + 4 { f 1 + f 3 + f 5 + + f N 1 } + 2 { f 2 + f 4 + f 6 + + f N 2 } + 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 ) .

The formula in Key Point 9 is slightly more complicated than the corresponding one for composite trapezium rule. One way of remembering the rule is the learn the pattern

1 4 2 4 2 4 2 4 2 4 2 4 1

which show that the end point values are multiplied by 1, the values with odd-numbered subscripts are multiplied by 4 and the interior values with even subscripts are multiplied by 2.

Example 15

Using 4 subintervals in the composite Simpson’s rule 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 + 4 f 1 + 2 f 2 + 4 f 3 + f 4 = 1 2 ( 0.5 ) 1 + 4 × 1.127626 + 2 × 1.543081 + 4 × 2.352410 + 3.762196 = 3.628083 ,

where this approximation is given to 6 decimal places.

This approximation to 0 2 cosh ( x ) d x is closer to the true value of sinh ( 2 ) (which is 3.626860 to 6 d.p.) than we obtained when using the composite trapezium rule with the same number of subintervals.

Task!

Using 4 subintervals in the composite Simpson’s rule approximate

1 2 ln ( x ) d x .

In this case h = ( 2 1 ) 4 = 0.25 . There will be five x -values and the results are tabulated below to 6 d.p.

x n f n = ln ( x n ) ̲ ̲ 1.00 0.000000 1.25 0.223144 1.50 0.405465 1.75 0.559616 2.00 0.693147

It follows that

1 2 ln ( x ) d x 1 3 h f 0 + 4 f 1 + 2 f 2 + 4 f 3 + f 4 = 1 3 ( 0.25 ) 0 + 4 × 0.223144 + 2 × 0.405465 + 4 × 0.559616 + 0.693147 = 0.386260  to 6 d.p.

4.2 How good is the composite Simpson’s rule?

On page 39 (Key Point 8) we saw a formula for an upper bound on the error in the composite trapezium method. A corresponding result for the composite Simpson’s rule exists and is given in the following Key Point.

Key Point 10

Error in Composite Simpson’s Rule

The error in the N -subinterval composite Simpson’s rule approximation to a b f ( x ) d x is bounded above by

max a x b f ( i v ) ( x ) ( b a ) h 4 180

(Here f ( i v ) is the fourth derivative of f and h is the subinterval width, so N × h = b a .)

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

Example 16

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

f ( i v ) ( x ) < 5

for x between 1 and 5. Determine how many subintervals are required so that the composite Simpson’s rule used to approximate

1 5 f ( x ) d x

incurs an error that is guaranteed less than 0.005 .

Solution

We require that

5 × 4 h 4 180 < 0.005

This implies that h 4 < 0.045 and therefore h < 0.460578 .

Now N = 4 h and it follows that

N > 8.684741

For the composite Simpson’s rule N must be an even whole number and we conclude that the smallest number of subintervals which guarantees an error smaller than 0.005 is N = 10 .

Task!

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

f ( i v ) ( x ) < 12

for x between 2 and 6. Determine how many subintervals are required so that the composite Simpson’s rule used to approximate

2 6 f ( x ) d x

incurs an error that is guaranteed less than 0.0005 .

We require that

12 × 4 h 4 180 < 0.0005

This implies that h 4 < 0.001875 and therefore h < 0.208090 .

Now N = 4 h and it follows that

N > 19.222491

N must be an even whole number and we conclude that the smallest number of subintervals which guarantees an error smaller than 0.0005 is N = 20 .

The following Task is similar to one that we saw earlier in this Section (page 42). Using the composite Simpson’s rule we can achieve greater accuracy, for a similar amount of effort, than we managed using the composite trapezium rule.

Task!

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

  1. Use this fact to determine how many subintervals are required for the composite Simpson’s rule 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 4 .

    We require that 3 2 π ( b a ) h 4 180 < 0.00005 .

    This means that h 4 < 0.00751988 and therefore h < 0.294478 . Since N = 1 h it is necessary for N = 4 for the error bound to be guaranteed to be less than ± 1 2 × 1 0 4 .

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

    In this case h = ( 1 0 ) 4 = 0.25 . We require 1 2 π e x 2 2 evaluated at five x -values and the results are tabulated below to 6 d.p.

    x n 1 2 π e x n 2 2 ̲ ̲ 0 0.398942 0.25 0.386668 0.5 0.352065 0.75 0.301137 1 0.241971

    It follows that

    0 1 1 2 π e x 2 2 d x 1 3 h f 0 + 4 f 1 + 2 f 2 + 4 f 3 + f 4 = 1 3 ( 0.25 ) 0.398942 + 4 × 0.386668 + 2 × 0.352065 + 4 × 0.301137 + 0.241971 = 0.341355  to 6 d.p.

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

Example 17

Find out how many strips are needed to be sure that

0 4 sinh ( 2 t ) d t

is evaluated by Simpson’s rule with error less than ± 0.0001

Solution

E = ( b a ) 180 h 4 ( 16 ) sinh ( 2 x ) 0 < x < 4

E 64 h 2 sinh ( 8 ) 180 0.0001

h 4 0.0180 64 sinh ( 8 ) h 0.0208421

n h = b a n 4 0.0208421 = 191.92

So n = 192 is needed (minimum even number).