\documentclass[11pt]{article}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{multicol}


\title{Math 1a.  Lecture 6 \\
Approximate Integration}

\author{T. Judson}

\date{Spring 2006}


\begin{document}

\maketitle


\section{Goals\protect\footnote{A calculator is useful for this lesson.}}

\begin{itemize}

\item
To understand and be able to the Midpoint Rule to approximate definite integrals.

\item
To understand and be able to the Trapezoid Rule to approximate definite integrals.

\item
To understand and be able to Simpson's Rule to approximate definite integrals.

\item
To understand and be able to apply error estimates for the Midpoint, Trapezoid, and Simpson's Rule


\end{itemize} 



\section{Approximating Integrals Numerically}



Suppose that we wish to compute
$$
\int_0^1 \sin(x^2) \, dx.
$$
Although the Fundamental Theorem of Calculus guarantees that 
$$
F(x) = \int_0^t \sin(t^2) \, dt
$$
is an antiderivative of $\sin(x^2)$, it is not possible to express this antiderivative in terms of elementary functions.

\section{Midpoint and Trapezoid Rules}

We can certainly use left and right sums to estimate
$$
\int_a^b f(x) \, dx.
$$
That is,
\begin{gather*}
\int_a^b f(x) \, dx \approx L_n = \sum_{i=1}^n f(x_{i-1}) \Delta x \\
\int_a^b f(x) \, dx \approx R_n = \sum_{i=1}^n f(x_i) \Delta x,
\end{gather*}
where $\Delta = (b-a)/n$.
A better strategy is to estimate the height of the function in each subinterval $[x_{i-1}, x_i]$ using the midpoint of the subinterval, $(x_{i-1} + x_i)/2$.  This gives us the {\em Midpoint Rule},\footnote{It is easy to develop the Midpoint and Trapezoid Rules using the graph of the function.  It is also important to write out each of these rules {\em without\/} using summation notation.}
$$
\int_a^b f(x) \, dx \approx M_n = \sum_{i=1}^n f\left(  \frac{x_{i-1} + x_i}{2} \right) \Delta x.
$$

If we approximate $f(x)$ by a linear function on each subinterval $[x_{i-1}, x_i]$, then we have the {\em Trapezoid Rule},
$$
\int_a^b f(x) \, dx \approx T_n = \sum_{i=1}^n \frac{f(x_{i-1}) + f(x_i)}{2}\Delta x.
$$

\section{Example}


Consider $I = \int_0^1 \sin( x^2) \, dx$.
\begin{enumerate}

\item
If $n = 8$, use a Left Sum  to estimate $I$.

\item
If $n = 8$, use a Right Sum  to estimate $I$.

\item
If $n = 8$, use the Midpoint Rule to estimate $I$.

\item
If $n = 8$, use the Trapezoid Rule to estimate $I$.

\end{enumerate}


\section{Simpson's Rule}

Simpson's Rule is based on using quadratic functions to estimate $f(x)$, instead of constant or linear functions.


\begin{multline*}
\int_a^b f(x) \, dx \approx S_n =  [f(x_0) + 4 f(x_1) + 2 f(x_2) + 4 f(x_3) + \cdots + \\ 2 f(x_{n-2}) + 4 f(x_{n-1}) + f(x_n)] \frac{\Delta x}{3},
\end{multline*}
where $\Delta = (b-a)/n$.

Understanding Simpson's Rule geometrically is a three-step process.\footnote{Leave this section for last in case there is not enough time.  Students can read about the exact steps on pp. 416--417 in Stewart.}
\begin{enumerate}

\item
Partition $[a, b]$ into an {\em even\/} number of equal subdivisions, each with width $\Delta = (b-a)/n$.  Consider successive {\em pairs\/} of subdivisions.

\item
Each pair involves {\em three\/} equally spaced points: $-h$, $0$, and $h$.  Over each such double subinterval, replace the integrand $f$ with a quadratic that passes through the points 
\begin{gather*}
(-h, f(-h)) \\ (0, f(0)) \\  (h, f(h)).
\end{gather*}
For algebraic reasons, only one such function $q$ exists.  If the three points are collinear, then $q$ will be a linear function.

\item
The area under (over if $f < 0$) each small parabolic arc is 
\begin{eqnarray*}
\int_{-h}^h Ax^2 + Bx + C \, dx
& = &
\underbrace{\int_{-h}^h Ax^2 + C \, dx}_{\mbox{even}} + \underbrace{\int_{-h}^h  Bx  \, dx}_{\mbox{odd}} \\
& = & 
2\int_0^h Ax^2 + C \, dx \\
& = & 
\frac{h}{3} (2Ah^2 + 6C).
\end{eqnarray*}
Since the quadratic passes through the points $P_0 = (-h, y_0)$, $P_1= (0, y_1)$, and $P_2 = (h, y_2)$,
we know that
\begin{eqnarray*}
y_0 & = & Ah^2 - Bh + C \\
y_1 & = & C \\
y_2 & = & Ah^2 + Bh + C
\end{eqnarray*}
Thus,
$$
y_0 + 4 y_1 + y_2 = 2Ah^2 + 6C
$$
Summing up all $n/2$ contributions give $S_n$, Simpson's Rule.

\end{enumerate}

\section{Example}

Use Simpson's rule to estimate $I = \int_0^1 \sin( x^2) \, dx$ if $n = 8$.




\section{Error for the Midpoint and Trapezoid Rules}

How accurate is each method.  If we examine graphs approximated by linear functions or constant functions, it is clear that concavity of the function will determine error.  Suppose that concavity is bounded, say $|f''(x)| \leq K$ on the interval $[a, b]$.  Among all functions that satisfy this inequality, the quadratic
$$
q(x) = \frac{K x^2}{2}
$$
is the worst offender since $|q''(x)| \leq K$ for all $x$ in the interval $[a, b]$.  How much error can happen over a subinterval.  To simplify matters, we take $[0, h]$ to be our subinterval.  Then
\begin{gather*}
I_h = \int_0^h q(x) \, dx = \int_0^h \frac{K x^2}{2} \, dx = \frac{Kh^3}{6} \\
M_h = q\left( \frac{h}{2} \right) \cdot h = \frac{Kh^3}{8} \\
T_h = \frac{q(0) + q(h)}{2} \cdot h = \frac{Kh^3}{4} 
\end{gather*}
The errors can now be computed to be
\begin{eqnarray*}
|I_h - M_h | & = &  \frac{Kh^3}{24} \\
|I_h - T_h | & = &  \frac{Kh^3}{12}.
\end{eqnarray*}
Now replace $h$ by $(b-a)/n$ to get the following error estimates.

\medskip 

\begin{center}
\fbox{\parbox{\textwidth}{
Let $|f''(x)| \leq K$ on the interval $[a, b]$.
If $E_M$ and $E_T$ are the errors in the Trapezoid and Midpoint Rules, then
\begin{eqnarray*}
|E_T| & \leq & \frac{K(b - a)^3}{12n^2} \\
|E_M| & \leq & \frac{K(b - a)^3}{24n^2}.
\end{eqnarray*}
}}
\end{center}

\medskip


Let  $I = \int_0^1 \sin( x^2) \, dx$.
\begin{enumerate}

\item
How many subdivisions are needed to assure that the error is less than $10^{-6}$ if we use the Midpoint Rule to estimate $I$?


\item
How many subdivisions are needed to assure that the error is less than $10^{-6}$ if we use the Trapezoid Rule to estimate $I$?


\end{enumerate}


\section{Error for Simpson's Rule}

\medskip 

\begin{center}
\fbox{\parbox{\textwidth}{
Suppose that $|f^{(4)}(x)| \leq K$ on the interval $[a, b]$.  If $E_S$ is the errors in Simpson's Rule, then
$$
|E_S|  \leq \frac{K(b - a)^5}{180n^4}.
$$

If we use Simpson's Rule to estimate $I = \int_0^1 \sin( x^2) \, dx$, how many subdivisions are needed to assure that the error is less than $10^{-6}$?
}}
\end{center}

\medskip



\section*{References}

\begin{itemize}

\item
\S 5.9 in 
James Stewart.
{\it Single Variable Calculus: Concepts \& Context}, third edition.
Brooks/Cole, Belmont CA, 2005.
ISBN 0--534--41022--7.


\end{itemize}



\section*{Notes}

\subsection*{February 17, 2006}



\end{document}

