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

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.

>with(student);The following example will use the function

>f:=x->x^2*exp(x);This computes the integral of the function from 0 to 2.

>int(f(x),x=0..2);Using the

>evalf(int(f(x),x=0..2));The command for using the trapezoidal rule is

>trapezoid(f(x),x=0..2,10);Putting an

>evalf(trapezoid(f(x),x=0..2,10));The command for Simpson's rule is very similar.

>simpson(f(x),x=0..2,10); >evalf(simpson(f(x),x=0..2,10));

where

for some value between and that maximizes the second derivative in absolute value. Solving the error formula for guarantees a number of subintervals such that the error term is less than some desired tolerance . This gives:

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.

Similarly, the number of subintervals for the simpson rule approximation to guarantee an error smaller than is

- For the function
, use the trapezoidal rule formula to approximate the area under over the interval ising . Verify your answer using the
`trapezoid`command in Maple. Repeat this exercise with simpson's rule and Maple's`simpson`command. - For the function
over the interval , 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 necessary to approximate the value of the definite integral with error no greater than . Then do the same with Simpson's rule. Which is more accurate and why?
- (iii)
- Use the error estimate for the trapezoidal rule to find a value for , the number of subintervals, that ensures is within of the answer in part (i). How close is this answer to the number of subintervals you found in part (ii)?

(Hint: The part of the error term that is most difficult is . To find the maximum value of the second derivative of over the interval , an approximation based on the plot should suffice. To plot the second derivative of over the given interval, type the following command in Maple:plot(abs(diff(f(x),x,x)),x=0..5);

Then, using your mouse, click on the part of the plot that appears to be the maximum. When you click on a plot, coordinates will appear in the upper left hand corner of your Maple window and the coordinate is used for the max.) - (a)
- (iv)]
Repeat part (iii) using Simpson's rule.
(Hint: To maximize the fourth derivative of over the given interval, type the following command in Maple:
plot(abs(diff(f(x),x,x,x,x)),x=0..5);

2013-10-07