\documentclass[12pt]{article}
\usepackage{amsmath,amssymb,latexsym,graphicx,enumerate,verbatim,amsthm,verbatim,color}

\textwidth 6.5 true in
\textheight 9.0 true in
\topmargin -0.5 true in
\oddsidemargin 0.0 true in
\evensidemargin 0.0 true in

\definecolor{solcol}{rgb}{0,0,1}



\begin{document}

\begin{center}
Math 132: Calculus for the Physical \& Life Sciences 2

Lab Day 1: Understanding Errors for Approximate Integration

Due Friday, February 22, 2008, at the beginning of class.
\end{center}


\vskip 10pt
\noindent
{\it Background and Goals}
\vskip 10pt
We have discussed various methods for approximating definite integrals:
left- and right-hand Riemann sums ($L_n,R_n$), midpoint Riemann sums ($M_n$), 
the Trapezoidal Rule ($T_n$), and Simpson's Rule ($S_n$).  The main goal
of this lab is to study how the {\it error} for each of these
approximation methods:
\[
\text{Error} = \text{Exact Value} - \text{Approximate Value}.
\] 
depends on the number of subdivisions $n$ used to construct
the approximation.  We also want to understand why the weighted
average form of Simpson's Rule:
\begin{equation}\label{SRWA}
S_{2n} = \frac{2}{3} M_n + \frac{1}{3} T_n
\end{equation}
gives an explanation for why Simpson's Rule appears to be so much 
more accurate than the other methods. 
\vskip 10pt
\noindent
{\it Maple Commands} 

\vskip 10pt
The commands that you will need to use
are \texttt{RiemannSum}, \texttt{ApproximateInt} from the 
Student[Calculus1] package, which you load by typing
\begin{verbatim}
with(Student[Calculus1]);
\end{verbatim}
To enter a function, say $f(x)=x^3-2x^2-7x+4$, type

\begin{verbatim}
f := x-> x^3-2*x^2-7*x+4;
\end{verbatim}

To compute one of the Riemann sum approximations, say the 
midpoint sum over the interval $[-2,4]$ with $n = 8$ subintervals
use
\begin{verbatim}
evalf(RiemannSum(f(x),x=-2..4,method=midpoint,partition=8));
\end{verbatim}
To compute one of the other approximations, say the Trapezoid Rule over the
interval $[-2,4]$ with $n=8$ subintervals, type
\begin{verbatim}
evalf(ApproximateInt(f(x),x=-2..4,method=trapezoid,partition=8));
\end{verbatim}
To plot the graph of a function over an interval, use the \texttt{plot} command.
\begin{verbatim}
plot(f(x),x=-2..4);
\end{verbatim}

\vskip 10pt
\noindent
{\it A Comment}  

\vskip 10pt
As we discussed in class on Wednesday, in Maple,
the command \texttt{ApproximateInt} with the \texttt{method=simpson}
and \texttt{partition=n} options actually corresponds to 
the Simpson's Rule approximation $S_{2n}$ the way we wrote
down the formula to start in class.  Since the weighted average 
form (\ref{SRWA}) of Simpson's Rule relates $S_{2n}$ to $M_n$ and $T_n$, though,
{\it we will always take equal partition numbers ($n$ values) for all
three methods when making comparisons}.  

\vskip 10pt
\noindent
{\it Lab Questions}
\vskip 10pt

\noindent
I.  You will first work with the definite integral
    \[
    \int_0^1 x^2\sqrt{4-x^2}\,dx=\frac{\pi}3-\frac{\sqrt{3}}{4}\approx 0.6141848494
    \]
In Maple, $\pi$ is entered as \texttt{Pi} and the command \texttt{sqrt} is the square root function.

\begin{enumerate}
\item[A)] (Do before or after the lab.)
Verify the exact value of the integral above, using a trig substitution.
\item[B)] Complete Table A on the accompanying sheet 
for the function $f(x)=x^2\sqrt{4-x^2}$ over $[0,1]$. (Compute the values
using Maple, and fill in the table by hand, recording \emph{all} decimal
places Maple displays.)
\item[C)] For each method, when you double $n$, the error should be (approximately)
divided by $2^p$ for some power $p$. Find that power for each of the methods.
Put your results in the Table B on the accompanying page.
\item[D)]  For each method the error can be estimated as
    \[
    \boxed{E(n)\approx\frac{k}{n^p}}
    \]
where $p$ is the power in the table above and $k$ is some constant.
In each method, determine the effect on the error of multiplying $n$ by 10
and put your results in Table C.  
\item[E)] Take $n = 16$.  How do the errors for the Midpoint Riemann sum $M_n$ and the 
Trapezoidal rule $T_n$ compare?  
\item[F)] Based on your answer to part D, about how large would $n$ have to 
be for $M_n$ to be accurate to $10$ decimal places (that is, the error for
$M_n$ to be less than $.5 \times 10^{-10}$).  Compute $M_n$ for your $n$
and compare to the exact value.  
\end{enumerate}

\vskip 10pt
\noindent
II.  Repeat question I for the integral
\[
\int_0^1 e^{x^2}\,dx
\]
(which cannot be evaluated by means of the Evaluation Theorem because
$f(x) = e^{x^2}$ has no antiderivative in the class of elementary functions).  
How will you get an ``exact'' value to approximate the errors for the four
methods for $n = 2,4,8,16$?

\vskip 10pt
\noindent
III.  
\begin{enumerate}
\item[A)]  (Do before or after lab.)
Explain why $S_{2n}$ is always between $M_n$ and $T_n$.
{\it Hint:} Either $M_n \leq T_n$ or $T_n \leq M_n$.
Consider each case separately.
\item[B)] Based on your answers to part A above 
and parts I E and II E, explain 
why it is reasonable that Simpson's Rule
should produce much more accurate estimates for the same {\tt partitions} 
number $n$ than either the Midpoint Rule or the Trapezoidal rule for 
the same $n$.   See the weighted average form (\ref{SRWA}) above.
\end{enumerate}

\vfill\eject
\noindent
\begin{center}
Approximations for $\int_0^1 x^2\sqrt{4-x^2}\,dx$
\end{center}
\vskip 20pt
Table A
\begin{center}
\begin{tabular}{|l||l|l|l|l|}
\hline
$n$ & 2\qquad\qquad\qquad\  & 4\qquad\qquad\qquad\  & 8 \qquad\qquad\qquad\  & 16\qquad\qquad\qquad\ \\
\hline\hline
$L_n$ $\begin{matrix}\ \\\ \end{matrix}$ &
&&&\\
\hline
$E_{left}(n)$ $\begin{matrix}\ \\\ \end{matrix}$ &
&&&\\
\hline
\hline
$R_n$ $\begin{matrix}\ \\\ \end{matrix}$ &
&&&\\
\hline
$E_{right}(n)$ $\begin{matrix}\ \\\ \end{matrix}$ &
&&&\\
\hline
\hline
$M_n$ $\begin{matrix}\ \\\ \end{matrix}$ &
&&&\\
\hline
$E_{mid}(n)$ $\begin{matrix}\ \\\ \end{matrix}$ &
&&&\\
\hline
\hline
$T_n$ $\begin{matrix}\ \\\ \end{matrix}$ &
&&&\\
\hline
$E_{trap}(n)$ $\begin{matrix}\ \\\ \end{matrix}$ &
&&&\\
\hline
\hline
$S_{2n}$ $\begin{matrix}\ \\\ \end{matrix}$ &
&&&\\
\hline
$E_{simp}(n)$ $\begin{matrix}\ \\\ \end{matrix}$ &
&&&\\
\hline
\end{tabular}
\end{center}

\noindent
Table B
\vskip 10pt
\begin{center}
\begin{tabular}{|c||c|c|c|c|c|}
\hline
Method&LEFT&RIGHT&MID&TRAP&SIMP\\
\hline\hline
$p$ $\begin{matrix}\ \\\ \end{matrix}$&&
&&&
\\
\hline
\end{tabular}
\end{center}

Table C
\vskip 10pt
\begin{center}
\begin{tabular}{|c||c|c|c|c|c|}
\hline
Method&LEFT&RIGHT&MID&TRAP&SIMP\\
\hline\hline
Error is divided by: $\begin{matrix}\ \\\ \end{matrix}$&&
&&&
\\
\hline
\end{tabular}
\end{center}

\vfill\eject
\noindent
\begin{center}
Approximations for $\int_0^1 e^{x^2}\,dx$
\end{center}
\vskip 20pt
Table A
\begin{center}
\begin{tabular}{|l||l|l|l|l|}
\hline
$n$ & 2\qquad\qquad\qquad\  & 4\qquad\qquad\qquad\  & 8 \qquad\qquad\qquad\  & 16\qquad\qquad\qquad\ \\
\hline\hline
$L_n$ $\begin{matrix}\ \\\ \end{matrix}$ &
&&&\\
\hline
$E_{left}(n)$ $\begin{matrix}\ \\\ \end{matrix}$ &
&&&\\
\hline
\hline
$R_n$ $\begin{matrix}\ \\\ \end{matrix}$ &
&&&\\
\hline
$E_{right}(n)$ $\begin{matrix}\ \\\ \end{matrix}$ &
&&&\\
\hline
\hline
$M_n$ $\begin{matrix}\ \\\ \end{matrix}$ &
&&&\\
\hline
$E_{mid}(n)$ $\begin{matrix}\ \\\ \end{matrix}$ &
&&&\\
\hline
\hline
$T_n$ $\begin{matrix}\ \\\ \end{matrix}$ &
&&&\\
\hline
$E_{trap}(n)$ $\begin{matrix}\ \\\ \end{matrix}$ &
&&&\\
\hline
\hline
$S_{2n}$ $\begin{matrix}\ \\\ \end{matrix}$ &
&&&\\
\hline
$E_{simp}(n)$ $\begin{matrix}\ \\\ \end{matrix}$ &
&&&\\
\hline
\end{tabular}
\end{center}

\noindent
Table B
\vskip 10pt
\begin{center}
\begin{tabular}{|c||c|c|c|c|c|}
\hline
Method&LEFT&RIGHT&MID&TRAP&SIMP\\
\hline\hline
$p$ $\begin{matrix}\ \\\ \end{matrix}$&&
&&&
\\
\hline
\end{tabular}
\end{center}

Table C
\vskip 10pt
\begin{center}
\begin{tabular}{|c||c|c|c|c|c|}
\hline
Method&LEFT&RIGHT&MID&TRAP&SIMP\\
\hline\hline
Error is divided by: $\begin{matrix}\ \\\ \end{matrix}$&&
&&&
\\
\hline
\end{tabular}
\end{center}


\end{document}
