Approximating Integrals



Today: 7.7 - approximating integrals
Friday: Third QUIZ and 7.8 - improper integrals

Problem: Compute

$\displaystyle \int_0^1 e^{-\sqrt{x}} dx.
$

Hmmm... Any ideas?

Today we will revisit Riemann sums in the context of finding numerical approximations to integrals, which we might not be able to compute exactly. Recall that if $ y=f(x)$ then

$\displaystyle \int_a^b f(x) dx = \lim_{n\to\infty} \sum_{i=1}^n f(x_i^*) \Delta x.
$

The fundamental theorem of calculus says that if we can find an antiderivative of $ f(x)$, then we can compute $ \int_a^b f(x) dx$ exactly. But antiderivatives can be either (1) hard to find, and sometimes worse (2) impossible to find. However, we can always approximate $ \int_{a}^b f(x) dx$ (possibly very badly).

For example, we could use Riemann sums to approximate $ \int_{a}^b f(x) dx$, say using left endpoints. This gives the approximation:

$\displaystyle L_n = \sum_{i=0}^{n-1} f(x_i) \Delta x; \qquad x_0, \ldots, x_{n-1}$    left endpoints

Using rightpoints gives

$\displaystyle R_n = \sum_{i=1}^{n} f(x_i) \Delta x; \qquad x_1, \ldots, x_{n}$    right endpoints

Using midpoints gives

$\displaystyle M_n = \sum_{i=1}^{n} f(\overline{x}_i) \Delta x; \qquad \overline{x}_1,
\ldots, \overline{x}_{n}$    midpoints$\displaystyle ,
$

where $ \overline{x}_i = (x_{i-1} + x_i)/2$. The midpoint is typically (but not always) much better than the left or right endpoint approximations.

Yet another possibility is the trapezoid approximation, which is

$\displaystyle T_n = \frac{1}{2}(L_n + R_n);
$

this is just the average of the left and right approximations.

Question 5.6.1   But wouldn't the trapezoid and midpoint approximations be the same?-certainly not (see example below); interestingly, very often the midpoint approximation is better.

Simpson's approximation

$\displaystyle S_{2n} = \frac{1}{3}T_n + \frac{2}{3} M_n
$

gives the area under best-fit parabolas that approximate our function on each interval. The proof of this would be interesting but takes too much time for this course.

Many functions have no elementary antiderivatives:

$\displaystyle \sqrt{1+x^3}, e^{-x^2}, \frac{1}{\log(x)}, \frac{\sin(x)}{x}, \ldots.
$

NOTE - they do have antiderivatives; the problem is just that there is no simple formula for them. Why are there no elementary antiderivatives?

Some of these functions are extremly important. For example, the integrals $ \int_{-\infty}^x e^{-u^2/2} du$ are extremely important in probability, even though there is no simple formula for the antiderivative.

If you are doing scientific research you might spend months tediously computing values of some function $ f(x)$, for which no formula is known.

Example 5.6.2   Compute $ \int_{0}^1 e^{-\sqrt{x}} dx$.
  1. Trapezoid with $ n=4$
  2. Midpoint with $ n=4$
  3. Simpson's with with $ 2n=8$
Figure 5.6.1: Graph of $ e^{-\sqrt{x}}$
% latex2html id marker 14241
\includegraphics[width=0.6\textwidth]{graphs/example_nint}

The following is a table of the values of $ f(x)$ at $ k/8$ for $ k=0,\ldots, 8$.

$ k/8$ $ f(k/8)$
0 $ V_{0} = 1.000000$
$ \frac{1}{8}$ $ V_{1} = 0.702189$
$ \frac{1}{4}$ $ V_{2} = 0.606531$
$ \frac{3}{8}$ $ V_{3} = 0.542063$
$ \frac{1}{2}$ $ V_{4} = 0.493069$
$ \frac{5}{8}$ $ V_{5} = 0.453586$
$ \frac{3}{4}$ $ V_{6} = 0.420620$
$ \frac{7}{8}$ $ V_{7} = 0.392423$
$ 1$ $ V_{8} = 0.367879$
<>

$\displaystyle L_4 = (V_0 + V_2 + V_4 + V_6) \cdot \frac{1}{4} = 0.630055$

$\displaystyle R_4 = (V_2 + V_4 + V_6 + V_8) \cdot \frac{1}{4} = 0.472025$

$\displaystyle M_4 = (V_1 + V_3 + V_5 + V_7) \cdot \frac{1}{4} = 0.522565$

$\displaystyle T_4 = \frac{1}{2}(L_4 + R_4) = 0.551040.$

$\displaystyle S_8 = \frac{1}{3} T_4 + \frac{2}{3} M_4 = 0.532057$

Maxima gives $ 0.5284822353142306$ and Mathematica gives $ 0.528482$.

Note that Simpsons's is the best; it better be, since we worked the hardest to get it!

Method Error
$ \vert L_4 - I\vert$ 0.101573
$ \vert R_4 - I\vert$ 0.056458
$ \vert M_4 - I\vert$ 0.005917
$ \vert T_{4} - I\vert$ 0.022558
$ \vert S_{8} - I\vert$ 0.003575
<>

William Stein 2006-03-15