% Numerical Integration
%\input mathhead.tex
%\magnification=\magstep1
%\magnification=\magstep1
%\nopagenumbers
\font\bigrm=cmr17
\font\medrm=cmr12
\font\medbf=cmbx12
\def\sc{\it}
\def\sectioncount{\count11}
\sectioncount=0
\def\theoremcount{\count12}
\theoremcount=0
\def\lemmacount{\count13}
\lemmacount=0
\def\corollarycount{\count14}
\corollarycount=0
\def\exerciseno{\count15}
\exerciseno=0
\def\algorithmcount{\count16}
\algorithmcount=0
\def\figurecount{\count17}
\figurecount=0
\def\ex{\advance\exerciseno by 1
        \item{\the\exerciseno.}
       }
\def\section#1{\advance\sectioncount by 1
     \medskip
     {\par \noindent \bf\the\sectioncount.\enskip #1.}
     \medskip
%     \headline={{\sl #1\hfil\the\pageno}}
     \theoremcount=0
     \lemmacount=0
     \corollarycount=0
    }
\long\def\longtheorem#1{\advance\theoremcount by 1
      \medskip
      {\bf\noindent Theorem \the\sectioncount.\the\theoremcount\ :
      \enskip}{\sl #1}
      \medskip
    }
\def\theorem#1{\advance\theoremcount by 1
      \medskip
      {\bf\noindent Theorem \the\sectioncount.\the\theoremcount\ :
      \enskip}{\sl #1}
      \medskip
    }
\long\def\longlemma#1{\advance\lemmacount by 1
      \medskip
      {\bf\noindent Lemma \the\sectioncount.\the\lemmacount\ :
      \enskip}{\sl #1}
      \medskip
    }
\def\lemma#1{\advance\lemmacount by 1
      \medskip
      {\bf\noindent Lemma \the\sectioncount.\the\lemmacount\ :
      \enskip}{\sl #1}
      \medskip
    }
\long\def\longcorollary#1{\advance\corollarycount by 1
      \medskip
      {\bf\noindent Corollary \the\sectioncount.\the\corollarycount\ :
      \enskip}{\sl #1}
      \medskip
    }
\def\corollary#1{\advance\corollarycount by 1
      \medskip
      {\bf\noindent Corollary \the\sectioncount.\the\corollarycount\ :
      \enskip}{\sl #1}
      \medskip
    }
\long\def\longalgorithm#1{\advance\algorithmcount by 1
      \medskip
      {\bf\noindent Algorithm \the\sectioncount.\the\algorithmcount\ :
      \enskip}{\sl #1}
      \medskip
    }
\def\algorithm#1{\advance\algorithmcount by 1
      \medskip
      {\bf\noindent Algorithm \the\sectioncount.\the\algorithmcount\ :
      \enskip}{\sl #1}
      \medskip
    }
\long\def\figure#1#2#3{\advance\figurecount by 1
                \vbox{
                      \vskip #1
                      \special{psfile="#2"}
                      \vskip .3true in
                      \centerline{Figure\ \the\figurecount.}
                     }
                \medskip
                \figurelabel{#3}
            }
\def\proof{{\bf\noindent Proof}:\enskip}
%\def\qed{\hfill \vrule width4pt height8pt depth0pt}
\def\qed{\hfill\vbox to 4pt{\hrule\hbox to 4pt
            {\vrule height 3pt depth 0pt \hfill \vrule}\vfill\hrule}
            \medskip
            }
\def\exerciselabel#1{\edef#1{\the\exerciseno}}
\def\theoremlabel#1{\edef#1{\the\sectioncount.\the\theoremcount}}
\def\lemmalabel#1{\edef#1{\the\sectioncount.\the\lemmacount}}
\def\corollarylabel#1{\edef#1{\the\sectioncount.\the\corollarycount}}
\def\algorithmlabel#1{\edef#1{\the\sectioncount.\the\algorithmcount}}
\def\figurelabel#1{\edef#1{\the\figurecount}}
\def\svs#1{{\sl S}_{#1}}
\def\dsvs#1{\dual{{\sl S}_{#1}}}
\def\dual#1{#1^*}
\def\comp#1{{\overline #1}}
\def\bibitem#1#2{
        \vbox{
          \smallskip\noindent \hangindent2\parindent \textindent{[#1]\ } #2}
        }
\def\Z{{\bf Z}}
\def\T{\top}
\def\true{\top}
\def\false{\bot}
\def\F{\bot}
\def\iff{\leftrightarrow}
\def\underline#1{{\bf #1}}
\def\notequal{\not=}
\def\plusminus{\pm}
\def\circle{\circ}
\def\N{{\rm\bf N}}
\def\Z{{\rm\bf Z}}
\def\R{{\rm\bf R}}
\def\Q{{\rm\bf Q}}
\def\C{{\rm\bf C}}
\def\page{\vfill\eject}
\def\title#1{\centerline{\bigrm #1}\bigskip}

\def\author#1{\centerline{\bf #1}\par}
\def\department#1{\centerline{#1}\par}
\def\university#1{\centerline{#1}\par}
\def\address#1{\centerline{#1}\par}

\def\by#1#2#3#4{\author{#1}\department{#2}\university{#3}\address{#4}
                \bigskip}
\def\({\left (}
\def\){\right )}
\def\[{\left [}
\def\]{\right ]}
\def\lf{\left\lfloor}
\def\rf{\right\rfloor}
\def\lc{\left\lceil}
\def\rc{\right\rceil}
\nopagenumbers


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                              %    
%                PROJECT STARTS HERE                           %
%                                                              %
%                                                              %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\centerline{\bigrm Numerical Integration}
\bigskip

\noindent
{\bf Purpose.} The purpose of this project is to derive formulas for upper bounds on
the amount of error you get from using a numerical method to approximate
an integral.  When you are finished with the project you should
understand the error using Riemann sums and the
trapezoid rule.

\noindent
{\bf The story.} Your friend Sue is an electrical engineering student who
is trying to design a digital filter.  Her professor told her to take
the Gibbs phenomenon into account in her design.  In order to do this,
she needs values for:

$$\int_0^b {\sin x\over x} dx$$

\noindent
for $b=0.10,0.20,0.30,0.40,\cdots, 2.00$.  Furthermore, she wants to be
sure all the numbers she gets are accurate to within $0.000005$.
She knows that it is hopeless to find 
the antiderivative of ${\sin x\over x}$.
She that you
are taking calculus and probably remember the formulas used to
integrate functions numerically, so she asks for your help.  Your job is to
make a table of values for the above integral.  You must be able to
prove to Sue that your answers are within the accuracy that she needs.

\noindent
{\bf Procedure.} You are to follow the outline below.  In the first 4
steps do not assume that the function is $f(x)={\sin x\over x}$.  
After you derive the appropriate formulas, then in step 5
you will apply what you learned to the special function under
consideration.  Before you start you may wish to look at the error
bounds in the book using the Trapezoid rule and using Simpson's rule.
The error bounds you derive will probably not be quite as good as those
in the book, but they will be close.

\item{1.}Before you get started with the project you should be aware of
         a fact about integrals.  Draw a picture to illustrate the
         inequality $|\int_a^b f(x) dx|\leq \int_a^b |f(x)| dx$ and
         explain why it is true.  You need not give a proof, but you
         should give a careful explanation.  This fact may be useful in
         later steps.
\item{2.}First you are to analyze how close a Riemann sum is to the
         actual integral.  You are to assume that you have a function
         $f(x)$ whose derivative is continuous on the interval $[a,b]$.
         Furthermore, assume that $|f'(x)|\leq M$ for every $a\leq x\leq b$.
 \itemitem{a.}Write the Riemann sum for $\int_a^b f(x) dx$ using the
         left end points.  
 \itemitem{b.}For each subinterval $[x_{i-1},x_i]$ of the partition of 
         $[a,b]$ consider the function $g(x)=f(x)-f(x_{i-1})$. First,
         note how the derivative of $f$ and the derivative of $g$
         compare.  Use an initial value problem to write the value of
         $g(x)$ in terms of an integral and $g(x_{i-1})$.  Using this
         formula, give an upper bound for $|g(x)|$ when $x$ is in the
         interval $[x_{i-1},x_i]$.
 \itemitem{c.}How does the integral of $g(x)$ relate to the error in
         approximating $\int_a^b f(x) dx$ with the Riemann sum using 
         left end points?  Use your estimate in part b) to derive an
         upper bound for the absolute value of the error on the interval $[x_{i-1},x_i]$.
 \itemitem{d.}Now use the error estimate you gave in part c) to derive
         an error estimate over the whole interval $[a,b]$.  Your answer
         should involve $a$, $b$, $M$, and $n$, but not $x_i$ or $x_{i-1}$.
 \itemitem{e.}Try computing $\int_0^{\pi} \sin x dx$ using left end
         points for $n=10,20,30,40$ using a computer or calculator.  
         Since you know the value of the
         integral, you can compare the actual value of the integral to
         the estimate you get from Riemann sums.  Is your error estimate
         close to what you expect it to be?  You may want to draw a
         graph to illustrate how close your estimates for the error are
         to the actual error in using the Riemann sum.  Next, do the same for 
         $\int_0^{\pi} \sin x dx$.  Explain why in one case the error 
         estimate is closer to the actual error than in the other case.
\item{3.}Next you will analyze how close the Trapezoid rule is to the
         actual value of the integral.  The error you derive will not be as
         close to the actual error as the estimate in the book, but it
         will still give an estimate which is at least as large as the
         actual error.  For this part we will assume that $f''(x)$ is
         continuous on the interval $[a,b]$.
 \itemitem{a.}Let $T(f,n)$ denote the answer you get when you apply the
         Trapezoid rule to $f$ using $n$ subintervals.  Show that if $f$
         and $g$ are functions then $T(f+g,n)=T(f,n)+T(g,n)$ for any
         $n$.
 \itemitem{b.}Let $E(f,n)=\int_a^b f(x)dx - T(f,n)$ 
         denote the error from using the Trapezoid
         method in computing the integral of $f$.  Show that if $f$ is a
         linear function ($f(x)=mx+c$), then $E(f,n)=0$.  Also show that
         $E(f+g,n)=E(f,n)+E(g,n)$ and $E(cf,n)=cE(f,n)$ where $c$ is a 
         constant and $f$ and $g$ are continuous functions on $[a,b]$.
 \itemitem{c.}Write the Trapezoid rule and separate out the part
         corresponding to the $i^{\rm th}$ subinterval in the partition
         of $[a,b]$.  You will estimate the error in each subinterval
         and then add your estimates together to get an estimate on the
         total error.
 \itemitem{d.}In the $i^{\rm th}$ subinterval, let $g(x)$ be the
         function whose graph is the tangent line to $f(x)$ at 
         $x_{i-1}$.
 \itemitem{e.}Compute the first two derivatives of $h(x)=f(x)-g(x)$ and
         simplify as much as possible.  In particular, compute 
         $h(x_{i-1})$ and $h'(x_{i-1})$.
 \itemitem{f.}For the rest of 3) assume that $|f''(x)|\leq M$ for
         some constant $M$ and every $x$ in $[a,b]$.   Use this
         assumption to estimate $|h'(x)|$ by using an initial value
         problem.
 \itemitem{g.}Now use your estimate in part f) to estimate $|h(x)|$, again
         using an initial value problem.
 \itemitem{h.}Estimate the integral of $|h|$ using your results in part
         g).
 \itemitem{i.}Estimate what you get using the Trapezoid rule on $h$ for
        the subinterval $[x_{i-1},x_i]$.  Then combine this estimate
        with what you have in h) to get an estimate for the error 
        using the Trapezoid rule on $[x_{i-1},x_i]$.
 \itemitem{j.}Compare the error in using the Trapezoid rule on $f$ and
        on $h$ for the subinterval $[x_{i-1},x_i]$ to estimate the error on
        $f$.  Add up the error estimates on the subintervals to get an
        estimate for $E(f,n)$.
 \itemitem{k.}Do 2) part e)using the Trapezoid rule and integrating 
        $\int_{-\pi\over 2}^{\pi\over 2}\sin x dx$ and $\int_{0}^{\pi\over 2}\sin x dx$.  
        Which gives an error estimate closer to the actual error?  Explain why.
\item{4.}Now consider the special function $f(x)={\sin x\over x}$.
 \itemitem{a.}First you need an estimate of the appropriate derivatives of $f$.
        Use Mathematica, Maple, or your graphing calculator to estimate
        these from a graph.  Note that at $x=0$ there may be a slight
        problem.  Does the graph show a problem?  Explain.
 \itemitem{b.}Now use the estimates
        you derived to decide what $n$ should be to get the
        values of the integral within the desired error bounds for 
        each of the three methods.  Comment about which method is more
        efficient.
 \itemitem{c.}Write a program (use Mathematica, Maple, C, Basic, or even
        a calculator) to compute the desired integrals.  You may use
        whichever method you desire.  (You may even use Simpson's method 
        if you do the extra credit.)

\noindent
If you haven't had enough fun yet, try deriving a formula for the error term using Simpson's formula.  This is for extra credit, and is not required.

   
\bye
