Subsections

# Numerical Integration

## Purpose

The purpose of this lab is to give you some experience with using the trapezoidal rule and Simpson's rule to approximate integrals.

## Getting Started

To assist you, there is a worksheet associated with this lab that contains examples and even solutions to some of the exercises. You can copy that worksheet to your home directory with the following command, which must be run in a terminal window, not in Maple.

cp ~bfarr/NumInt_start.mws ~


You can copy the worksheet now, but you should read through the lab before you load it into Maple. Once you have read to the exercises, start up Maple, load the worksheet NumInt_start.mws, and go through it carefully. Then you can start working on the exercises.

## Background

In class we have talked about the trapezoidal rule and Simpson's rule for approximating the definite integral

Both methods start by dividing the interval into subintervals of equal length by choosing a partition

satisfying

where

is the length of each subinterval. For the trapezoidal rule, the integral over each subinterval is approximated by the area of a trapezoid. This gives the following approximation to the integral

There is also an error term associated with the trapezoidal rule that can be used to estimate the error. More precisely, we have

where

for some value between and .

One way to use this error term is as a way to bound the number of subintervals required to achieve a certain tolerance. That is, suppose is a small number and we want to determine a value of that guarantees

If we substitute the error formula from above into this inequality and rearrange it to isolate we get the following.

Now, if we let be the maximum of on the interval , we can take the square root of both sides of the equation to obtain the following estimate for .

The way to think about this result is that it gives a value for which guarantees that the error of the trapezoidal rule is less than the tolerance . It is generally a very conservative result. As you will discover in the exercises, the actual number of subintervals required to satisfy the tolerance is usually much smaller than the number given by the error estimate.

For Simpson's rule, the function is approximated by a parabola over pairs of subintervals. When the areas under the parabolas are computed and summed up, the result is the following approximation.

As for the trapezoidal rule, there is an error formula which says that

where

for some value between and .

As we did for the trapezoidal rule, we can rearrange this formula to allow us to estimate the number of subintervals required so that we can guarantee

Using essentially the same steps as we used for the trapezoidal rule, we get the following inequality.

where is the maximum of on the interval .

## Exercises

1. The Getting started worksheet contains two proofs of the following result,

which is Simpson's rule applied to the interval using two subintervals. Explain why this result implies the formula given below for Simpson's rule over subintervals, where is even.

2. For the following functions and intervals, complete the following steps.
(i)
By using Maple's int and, possibly, evalf commands, find a good approximation to the integral of the function over the given interval.
(ii)
Find the minimum number of subintervals required so that satisfies the tolerance

Compare this number to the one you would get by using the error estimate for the trapezoidal rule.
(iii)
Find the minimum number of subintervals required so that satisfies the tolerance

Compare this number to the one you would get by using the error estimate for Simpson's rule.
1. , interval .
2. , interval .
3. Consider the error function

Use Simpson's rule to approximate to within an accuracy of and determine the minimum number of subintervals required. In a previous lab, you used Taylor polynomials to approximate this same integral. Which method do you think is better? Justify your answer.

4. Consider the function

Using Simpson's rule, find the minimum number of steps required to approximation each of the two integrals below to within .

and

Can you use the error estimate to explain why there is such a big difference between the number of subintervals required?

5. Simpson's rule usually requires fewer subintervals than the trapezoidal rule for the same accuracy, but this is not always true. Consider the following integral.

For this integral, you should find that with an equal number of subintervals, the trapezoidal rule gives a more accurate answer. Verify that this is true for several values of , . Can you explain this by using the error estimates?