next up previous
Next: Richardson Extrapolation Up: Approximating the Definite Integral Previous: The Trapezoidal Rule

Simpson's Rule

The second method that we shall develop is called Simpson's Rule. In this method we approximate f(x) with a collection of arcs from quadratic functions and integrate across each of these.

Once again let P be a partition of [a,b] into n subintervals of equal width, tex2html_wrap_inline2119, where tex2html_wrap_inline2121 for tex2html_wrap_inline2123. Here we require that n be even. Over each interval tex2html_wrap_inline2419, for tex2html_wrap_inline2421, we approximate f(x) with a quadratic curve that interpolates the points tex2html_wrap_inline2425, tex2html_wrap_inline2137, and tex2html_wrap_inline2139.

  figure288
Figure 4:   Approximating the graph of y = f(x) with parabolic arcs across successive pairs of intervals to obtain Simpson's Rule.

Since only one quadratic function can interpolate any three (non-colinear) points, we see that the approximating function must be unique for each interval tex2html_wrap_inline2419. Note that the following quadratic function interpolates the three points tex2html_wrap_inline2425, tex2html_wrap_inline2137, and tex2html_wrap_inline2139:

eqnarray298

Since this function is unique, this must be the quadratic function with which we approximate f(x) on tex2html_wrap_inline2419. Also, if the three interpolating points all lie on the same line, then this function reduces to a linear function. Therefore, since tex2html_wrap_inline2155 for each i,

eqnarray316

By evaluating the integral on the right, we obtain

displaymath2449

Summing the definite integrals over each interval tex2html_wrap_inline2419, for tex2html_wrap_inline2421, provides the approximation

eqnarray337

By simplifying this sum we obtain the approximation scheme

  equation347

This method of approximation is known as Simpson's Rule.

Example 9 As we did for the Trapezoidal Rule, let us now apply Simpson's Rule with n = 6 to approximate the value of

displaymath2207

Once again we have tex2html_wrap_inline2211 and

displaymath2213

for tex2html_wrap_inline2215. Simpson's Rule then provides

displaymath2465

to nine decimal places. So here we have a better approximation of the value tex2html_wrap_inline2219. tex2html_wrap_inline2195

Example 10 Let us apply Simpson's Rule with n = 8 to approximate the value of

displaymath2225

As in Example 3, our function tex2html_wrap_inline2227, but here we have tex2html_wrap_inline2477 with

displaymath2479

for tex2html_wrap_inline2481. Rounded to nine decimal places, this gives

displaymath2483

Applying Simpson's Rule then provides

eqnarray384

tex2html_wrap_inline2195

Example 11 Recall Example 5, where we found a sequence of approximations of the value of the definite integral

displaymath2487

by applying the Trapezoidal Rule with tex2html_wrap_inline2243. Here we shall find a sequence of approximations of the same definite integral by applying Simpson's Rule with n = 2, 4, 6, 8, and 10. Once again, we shall build a table of values of tex2html_wrap_inline2501 for these n.

displaymath2505

We see here that the values tex2html_wrap_inline2501 are converging to the value tex2html_wrap_inline2379 at a must faster rate than the values tex2html_wrap_inline2173 in Example 5. tex2html_wrap_inline2195

Example 12 The gamma function, tex2html_wrap_inline2515, is defined by the integral

displaymath2517

It is not difficult to see that tex2html_wrap_inline2519. Furthermore, this function satisfies the property

displaymath2521

Note that this implies that if n is a positive integer, then

displaymath2525

Thus tex2html_wrap_inline2515 is a function that interpolates all of the points (n,(n-1)!) for positive integers n. With the substitution

displaymath2533

the integral can be rewritten so that

displaymath2535

Thus we have a definite integral over the finite interval [0,1].

Now consider the function

displaymath2539

Note that for x > 1 this function is defined for all s in [0,1] except at s = 1. Since

displaymath2549

we can assign f(1) = 0 as part of our definition of f(s), making this function defined and continuous for all s in [0,1].

Let us apply Simpson's Rule with n = 4 to approximate the value of tex2html_wrap_inline2561. Then tex2html_wrap_inline2563, and tex2html_wrap_inline2565 for i = 0, 1, 2, 3, 4. Since x = 3/2, our function f(s) is of the form

displaymath2573

Rounded to nine decimal places, this gives

displaymath2575

When we apply Simpson's Rule we obtain

displaymath2577

The actual value of tex2html_wrap_inline2561 is tex2html_wrap_inline2581 (to nine places). Thus -.064088633 is the resulting error.

  figure419
Figure 5:   The curve tex2html_wrap_inline2585.

A problem that arises in this example is that as tex2html_wrap_inline2587, we have

displaymath2589

while

displaymath2591

In the evaluation of the function f(s), we find the product of the values of each of these. A considerable amount of error may be introduced at this point. tex2html_wrap_inline2195

Just as we have the doubling scheme for the Trapezoidal Rule, in which we incorporate (4) to derive tex2html_wrap_inline2293 from tex2html_wrap_inline2173, we can derive tex2html_wrap_inline2601 from the information gathered in obtaining tex2html_wrap_inline2501. First, let us denote

displaymath2605

Then from (6),

displaymath2607

Note that

displaymath2609

so that

displaymath2611

Thus to compute tex2html_wrap_inline2601, one must beforehand preserve the values of tex2html_wrap_inline2615 and tex2html_wrap_inline2617 obtained from the derivation of tex2html_wrap_inline2501. The only additional work then required is to find the sum tex2html_wrap_inline2621.

Using this same notation, the sum in (4) can be written

displaymath2623

We now wish to examine how accurately Simpson's Rule approximates the definite integral of f(x) on [a,b]. In this case the following has been proven:

Theorem 1.2 Suppose that tex2html_wrap_inline2629 exists on [a,b]. Then for n an even positive integer,

displaymath2635

where

displaymath2637

and the error tex2html_wrap_inline2323 is given by

displaymath2641

for some point c in [a,b].

Once again, the number c is not specified, and so we are not able to use this result to determine the exact value of tex2html_wrap_inline2323 for most functions f(x). However, we can see that the magnitude of the error has the bounds

displaymath2653

Example 13 We shall now find bounds on the error for the problem of using Simpson's Rule with n = 6 to approximate the value of

displaymath2207

For our function f(x) = 1/x, we have tex2html_wrap_inline2661, so that

displaymath2663

Now, tex2html_wrap_inline2629 is strictly decreasing for all x > 0, so that

displaymath2669

Example 14 In Example 10 we incorporated Simpson's Rule to approximate the value of

displaymath2671

with n = 8. For our function tex2html_wrap_inline2227, we have

displaymath2677

With some work it can be shown that tex2html_wrap_inline2679 for tex2html_wrap_inline2371. Therefore tex2html_wrap_inline2629 is increasing on [1,e], and so

displaymath2687

The following Mathematica program applies Simpson's rule to approximate the area under a given curve y = f(x) on an interval [a,b]. In its present form, it is written for the purpose of finding the area under the curve tex2html_wrap_inline2693 on the interval [1,e] starting with n = 6 divisions of the interval. The program will continue to double the number of divisions until the magnitude of the difference between consecutive approximations of the definite integral is less than a given value (in this case .0005).

       f[x_]:=Exp[x]*Log[x]
       a:=1.
       b:=Exp[1.]
       n:=6
       If[Mod[n,2]==0,
          Bn:=0;
          Cn:=Sum[f[a+2*i*(b-a)/n],{i,1,(n-1)/2}];
          sum1:=1.0;
          sum2:=0.0;
          While[Abs[sum2-sum1]>=.0005,
             sum1=sum2;
             delta=(b-a)/n;
             Cn=Bn+Cn;
             Bn=Sum[f[a+(2*i-1)*delta],{i,1,n/2}];
             sum2=delta*(f[a]+f[b]+4*Bn+2*Cn)/3;
             Print[n,"  ",N[sum2,20]];
             n=2*n],
          Print["The value of n, n = ",n,", is not even, and we cannot proceed."]]


next up previous
Next: Richardson Extrapolation Up: Approximating the Definite Integral Previous: The Trapezoidal Rule