next up previous
Next: Exercises Up: Labs and Projects for Previous: Purpose

Background

Trapezoidal rule and Simpson's rule
The rectangular rules that we used in the last lab are very simple to understand and use, but they are not very efficient. By this, we mean that a large number of subintervals is often required to get accurate results. Two widely used rules for approximating areas are the trapezoidal rule and Simpson's rule. The Maple student pakage has commands trapezoid and simpson that implement these methods. The command syntax is very similar to the rectangular approximations. See the examples below. Note that an even number of subintervals is required for the simpson command.

  > with(student);
  > trapezoid(x^2,x=0..4,4);

\begin{maplelatex}
\begin{displaymath}
{\displaystyle \left ( \sum_{{i}=1}^3\,{i}^{2} \right ) +8} \end{displaymath}\end{maplelatex}

  > evalf(trapezoid(x^2,x=0..4,4));

\begin{maplelatex}
\begin{displaymath}
22\end{displaymath}\end{maplelatex}

  > evalf(trapezoid(x^2,x=0..4,10));

\begin{maplelatex}
\begin{displaymath}
21.44000000\end{displaymath}\end{maplelatex}

  > simpson(x^2,x=0..4);

\begin{maplelatex}
\begin{displaymath}
\displaystyle \frac{16}{3} + \frac{4}{3} ...
 ...{2}{3} \left (\sum_{{i}=1}^1 {(4i^2)} \right ) \end{displaymath}\end{maplelatex}

  > evalf(simpson(x^2,x=0..4));

\begin{maplelatex}
\begin{displaymath}
21.33333333\end{displaymath}\end{maplelatex}

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

\begin{maplelatex}
\begin{displaymath}
21.3333333\end{displaymath}\end{maplelatex}

The trapezoidal rule uses trapezoids to approximate the area over the i-th subinterval as shown above with only two subintervals in the figure for y = x2 +1.

 
Figure 1:  Plot of f(x)=x2+1.
\begin{figure}
\includegraphics[height=2.0in,width=4.0in,angle=-90]{trap.ps}\end{figure}


Since the area of a trapezoid is the width times the average of the two heights, the area of the trapezoid above the i-th subinterval is


\begin{maplelatex}
\begin{displaymath}
\Delta x \frac{f(x_{i-1})+f(x_i)}{2}.\end{displaymath}\end{maplelatex}

Adding up all of the areas gives us the usual formula


\begin{maplelatex}
\begin{displaymath}
\Delta x \left ( \frac{f(x_0)}{2}+ \sum_{{i}=1}^{N-1}{f(x_i)} +\frac{f(x_N)}{2} \right ) \end{displaymath}\end{maplelatex}

for a uniform partition with N subintervals. You can think of the trapezoidal rule as the result of approximating the function by straight line segments.

The derivation of Simpson's rule is more complicated and will not be discussed here. It is described in detail in the text (Bradley and Smith pgs. 303-306). The basic idea is to fit the function f(x) with segments of parabolas. Three points are required to define a parabola, so two adjacent subintervals are used for each parabola segment. (This is why an even number of subintervals are required for Simpson's method.)


next up previous
Next: Exercises Up: Labs and Projects for Previous: Purpose

Christine M Palmer
3/20/1998