\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}
{\bf Math 132: Calculus for the Physical \& Life Sciences 2}

Spring 2005

Maple Lab 1: Approximation Errors

Professor Ballantine

{\bf Due Monday, February 27, 2006, at the beginning of class.}
\end{center}


\vskip 10pt

\noindent{\bf Purpose:} To investigate the accuracy of the numerical methods
LEFT$(n)$, RIGHT$(n)$, MID$(n)$, TRAP$(n)$ and SIMP$(n)$ for approximating definite
integrals. Recall that $$ \mbox{TRAP}(n)=\frac{\mbox{LEFT(n)}+\mbox{RIGHT}(n)}{2}.$$
SIMP$(n)$ is defined as
$$\mbox{SIMP}(n)=\frac{2\cdot\mbox{MID}(n)+\mbox{TRAP}(n)}{3}.$$\vspace{.1in}

\noindent The difference between the actual value of the definite integral and the
approximation is called the {\it error}. We will denote this by
    \[
    E(n)= \text{Approximation}-\text{Actual Value}
    \]


\vskip 10pt

\noindent{\bf Maple Commands:} The commands that you will need to use
are \texttt{leftsum}, \texttt{rightsum}, \texttt{middlesum}, \texttt{trapezoid}
and \texttt{simpson}. These are all part of the student package, which you load
by typing
\begin{verbatim}
with(student);
\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 approximations, say the Trapezoid Rule over the
interval $[-2,4]$ with $n=8$ subintervals, type
\begin{verbatim}
evalf(trapezoid(f(x),x=-2..4,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}
WARNING: The command \texttt{simpson} does not correspond exactly to SIMP.
To compute SIMP$(n)$, you will need to use \texttt{simpson} with $2n$.
For instance, to compute SIMP$(8)$ over $[-2,4]$ type
\begin{verbatim}
evalf(simpson(f(x),x=-2..4,16));
\end{verbatim}


\noindent{\bf Procedure:} 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 (Do before or after the lab.)
Verify the exact value of the integral above, using a trig substitution.
\item Complete the table below for the function $f(x)=x^2\sqrt{4-x^2}$ over $[0,1]$.
\end{enumerate}
\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
LEFT$(n)$ $\begin{matrix}\ \\\ \end{matrix}$ &
&&&\\
\hline
$E(n)$ $\begin{matrix}\ \\\ \end{matrix}$ &
&&&\\
\hline
\hline
RIGHT$(n)$ $\begin{matrix}\ \\\ \end{matrix}$ &
&&&\\
\hline
$E(n)$ $\begin{matrix}\ \\\ \end{matrix}$ &
&&&\\
\hline
\hline
MID$(n)$ $\begin{matrix}\ \\\ \end{matrix}$ &
&&&\\
\hline
$E(n)$ $\begin{matrix}\ \\\ \end{matrix}$ &
&&&\\
\hline
\hline
TRAP$(n)$ $\begin{matrix}\ \\\ \end{matrix}$ &
&&&\\
\hline
$E(n)$ $\begin{matrix}\ \\\ \end{matrix}$ &
&&&\\
\hline
\hline
SIMP$(n)$ $\begin{matrix}\ \\\ \end{matrix}$ &
&&&\\
\hline
$E(n)$ $\begin{matrix}\ \\\ \end{matrix}$ &
&&&\\
\hline
\end{tabular}
\end{center}

\begin{enumerate}
\setcounter{enumi}{2}

\item 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 below.
\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}


For each method the basic error estimate is therefore
    \[
    \boxed{E(n)\approx\frac{k}{n^p}}
    \]
where $p$ is the power in the table above.

\item In each method, determine the effect on the error of multiplying $n$ by 10.

\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{enumerate}



\noindent
Next consider the definite integral
    \[
    \int_0^1 e^{x^2}\,dx,
    \]
which cannot be evaluated analytically. In Maple, the exponential function $e^x$ is
entered as \texttt{exp(x)}.

\begin{enumerate}
\setcounter{enumi}{4}
\item\label{plot} Plot the graph of $g(x)=e^{x^2}$ over the interval $[0,1]$.
For each of the methods LEFT, RIGHT, MID and TRAP, determine whether it
will yield an overestimate or an underestimate. Use the graph of $g$ to explain why.



\item\label{max} Compute LEFT$(10)$ and RIGHT$(10)$. What is the most $E(10)$ could be for each method?
Why?


\item How large does $n$ need to be in order for LEFT$(n)$ and RIGHT$(n)$ to approximate
the integral to 9 decimal places? (For 9 decimal places accuracy, $E(n)$ must be at
most $0.5\times10^{-9}$.)


\item\label{midtraperr} Compute MID$(10)$ and TRAP$(10)$. What is the most $E(10)$ could be for each method?
Why?

\item How large does $n$ need to be in order for MID$(n)$ and TRAP$(n)$ to approximate
the integral to 9 decimal places?

\item\label{simpbounds} (Do before or after lab.)
Explain why SIMP$(n)$ is always between MID$(n)$ and TRAP$(n)$.
{\it Hint:} Either MID$(n)\leq\,\,$TRAP$(n)$ or TRAP$(n)\leq\,\,$MID$(n)$.
Consider each case separately.


\item Compute SIMP$(10)$. What is the most $E(10)$ could be for this method?
Use the results of questions \ref{midtraperr} and \ref{simpbounds}.



\item How large does $n$ need to be in order for SIMP$(n)$ to approximate
the integral to 9 decimal places? Write out the value of the integral to 9 decimal places.
\end{enumerate}




\end{document}
