Skip to main content

Section 2.6 Numerical Integration

We have now seen some of the most generally useful methods for discovering antiderivatives, and there are others. Unfortunately, some functions have no simple antiderivatives. In such cases, if the value of a definite integral is needed it will have to be approximated.

Interactive Demonstration. Choose an approximation Rule and then use the slider to investigate different types of approximations of a definite integral.

Subsection 2.6.1 Midpoint Rule

Of course, we already know from Section 1.3 one way to approximate an integral: If we think of the integral as computing an area, we can add up the areas of some rectangles (Riemann sum). While this is quite simple, it is usually the case that a large number of rectangles is needed to get acceptable accuracy. As pointed out before, the Midpoint Rule for the Riemann sum works best in most approximations that are based on rectangles.

Figure 2.1. A single rectangle.

In practice, an approximation is useful only if we know how accurate it is; for example, we might need a particular value accurate to three decimal places. When we compute a particular approximation to an integral, the error is the difference between the approximation and the true value of the integral. For any approximation technique, we need an error bound, a value that is guaranteed to be larger than the actual error. If \(A\) is an approximation and \(E\) is the associated error bound, then we know that the true value of the integral is between \(A-E\) and \(A+E\text{.}\) In the case of our approximation of the integral, we want \(E=E(\Delta x)\) to be a function of \(\Delta x\) that gets small rapidly as \(\Delta x\) gets small. Fortunately, for many functions, there is such an error bound associated with the midpoint approximation.

We will see two other methods that work reasonably well and yet are fairly simple; in some cases more sophisticated techniques will be needed.

Subsection 2.6.2 Trapezoid Rule

A similar approach is much better. We approximate the area under a curve over a small interval as the area of a trapezoid. This technique for approximating an integral is known as the Trapezoid Rule. In Figure 2.2 we see an area under a curve approximated by rectangles and by trapezoids; it is apparent that the trapezoids give a substantially better approximation on each subinterval.

Figure 2.2. Approximating an area with rectangles and with trapezoids.

As with rectangles, we divide the interval into \(n\) equal subintervals of length \(\Delta x\text{.}\) A typical trapezoid is pictured in Figure 2.6.2; it has area

\begin{equation*} \ds{f(x_i)+f(x_{i+1})\over2}\Delta x\text{.} \end{equation*}

If we add up the areas of all trapezoids we get

\begin{equation*} \begin{gathered} {f(x_0)+f(x_1)\over2}\Delta x+{f(x_1)+f(x_2)\over2}\Delta x+\cdots+ {f(x_{n-1})+f(x_n)\over2}\Delta x\\ =\left({f(x_0)\over2}+f(x_1)+f(x_2)+\cdots+f(x_{n-1})+{f(x_n)\over2}\right) \Delta x\\ =\frac{\Delta x}{2} \left(f(x_0) + 2f(x_1) + 2f(x_2) + \cdots + 2f(x_{n-1}) + f(x_n)\right). \end{gathered} \end{equation*}

For a modest number of subintervals this is not too difficult to do with a calculator; a computer can easily handle many subintervals.

Figure 2.3. A single trapezoid.

We summarize this result in the theorem below.

As with the midpoint method, this is useful only with an error bound:

Let's see how we can use this.

Example 2.47. Approximate an Integral With Trapezoids.

Approximate \(\ds\int_0^1 e^{-x^2}\,dx\) to two decimal places.

Solution

The second derivative of \(\ds f=e^{-x^2}\) is \(\ds(4x^2-2)e^{-x^2}\text{,}\) and it is not hard to see that on \([0,1]\) \(|f''(x)|\) has a maximum value of 2, thus we begin by estimating the number of subintervals we are likely to need. To get two decimal places of accuracy, we will certainly need \(E(\Delta x)\lt 0.005\) or

\begin{align*} {1\over12}(2){1\over n^2} \amp \lt 0.005\\ {1\over6}(200)\amp \lt n^2\\ 5.77\approx\sqrt{100\over3}\amp \lt n \end{align*}

With \(n=6\text{,}\) the error bound is thus \(\ds1/6^3\lt 0.0047\text{.}\) We compute the trapezoid approximation for six intervals:

\begin{equation*} \left({f(0)\over2}+f(1/6)+f(2/6)+\cdots+f(5/6)+{f(1)\over2}\right){1\over6} \approx 0.74512\text{.} \end{equation*}

The error bound gives an estimate of the error on either side of the approximation, and so the true value of the integral is between \(0.74512-0.0047=0.74042\) and \(0.74512+0.0047=0.74982\text{.}\) Unfortunately, the first rounds to \(0.74\) and the second rounds to \(0.75\text{,}\) so we can't be sure of the correct value in the second decimal place; we need to pick a larger \(n\text{.}\) As it turns out, we need to go to \(n=12\) to get two bounds that both round to the same value, which turns out to be \(0.75\text{.}\) For comparison, using \(12\) rectangles to approximate the area gives \(0.7727\text{,}\) which is considerably less accurate than the approximation using six trapezoids.

In practice it generally pays to start by requiring better than the maximum possible error; for example, we might have initially required \(E(\Delta x)\lt 0.001\text{,}\) or

\begin{align*} {1\over12}(2){1\over n^2} \amp \lt 0.001\\ {1\over6}(1000)\amp \lt n^2\\ 12.91\approx\sqrt{500\over3}\amp \lt n \end{align*}

Had we immediately tried \(n=13\) this would have given us the desired answer.

Subsection 2.6.3 Simpson's Rule

The trapezoid approximation works well, especially compared to rectangles, because the tops of the trapezoids form a reasonably good approximation to the curve when \(\Delta x\) is fairly small. What if we try to approximate the curve more closely by using something other than a straight line in our search for a better approximation to the integral of \(f\text{?}\) The obvious candidate is a parabola as shown in Figure 2.4: If we can approximate a short piece of the curve with a parabola with equation \(\ds y=ax^2+bx+c\text{,}\) we can easily compute the area under the parabola.

Figure 2.4. Approximating an area with parabolas.

There are an infinite number of parabolas through any two given points, but only one through three given points. If we find a parabola through three consecutive points \((x_i,f(x_i))\text{,}\) \((x_{i+1},f(x_{i+1}))\text{,}\) \((x_{i+2},f(x_{i+2}))\) on the curve, it should be quite close to the curve over the whole interval \([x_i,x_{i+2}]\text{,}\) as in Figure 2.6.3. If we divide the interval \([a,b]\) into an even number of subintervals, we can then approximate the curve by a sequence of parabolas, each covering two of the subintervals. For this to be practical, we would like a simple formula for the area under one parabola, namely, the parabola through \((x_i,f(x_i))\text{,}\) \((x_{i+1},f(x_{i+1}))\text{,}\) and \((x_{i+2},f(x_{i+2}))\text{.}\) That is, we should attempt to write down the parabola \(y=ax^2+bx+c\) through these points and then integrate it, and hope that the result is fairly simple. Although the algebra involved is messy, this turns out to be possible. The algebra is well within the capability of a good computer algebra system like Sage, so we will present the result without all of the algebra.

To find the parabola, we solve these three equations for \(a\text{,}\) \(b\text{,}\) and \(c\text{:}\)

\begin{align*} f(x_i)\amp =\amp a(x_{i+1}-\Delta x)^2+b(x_{i+1}-\Delta x)+c\\ f(x_{i+1})\amp =\amp a(x_{i+1})^2+b(x_{i+1})+c\\ f(x_{i+2})\amp =\amp a(x_{i+1}+\Delta x)^2+b(x_{i+1}+\Delta x)+c \end{align*}

Not surprisingly, the solutions turn out to be quite messy. Nevertheless, Sage can easily compute and simplify the integral to get

\begin{equation*} \int_{x_{i+1}-\Delta x}^{x_{i+1}+\Delta x} ax^2+bx+c\,dx= {\Delta x\over3}(f(x_i)+4f(x_{i+1})+f(x_{i+2}))\text{.} \end{equation*}

Now the sum of the areas under all parabolas is

\begin{equation*} \displaylines{ {\Delta x\over3}(f(x_0)+4f(x_{1})+f(x_{2})+f(x_2)+4f(x_{3})+f(x_{4})+\cdots +f(x_{n-2})+4f(x_{n-1})+f(x_{n}))=\cr {\Delta x\over3}(f(x_0)+4f(x_{1})+2f(x_{2})+4f(x_{3})+2f(x_{4})+\cdots +2f(x_{n-2})+4f(x_{n-1})+f(x_{n})).\cr} \end{equation*}

This is just slightly more complicated than the formula for trapezoids; we need to remember the alternating 2 and 4 coefficients, and that the interval must be divided into an even number of subintervals. This approximation technique is referred to as Simpson's Rule.

Figure 2.5. A parabola approximating a curve.

We capture our findings in the following theorem.

As with the trapezoid method, this is useful only with an error bound:

Note: Because of the factor \(180n^4\text{,}\) the error bound is usually much more accurate than that for the Trapezoid Rule or the Midpoint Rule. And since the formula is only slightly more complicated, Simpson's Rule is extremely useful and probably one of the most commonly used integral approximation rules in practice.

Example 2.50. Approximate an Integral With Parabolas.

Let us again approximate \(\ds\int_0^1 e^{-x^2}\,dx\) to two decimal places.

Solution

The fourth derivative of \(\ds f(x)=e^{-x^2}\) is \(\ds(16x^4-48x^2+12)e^{-x^2}\) and on \([0,1]\) this is at most \(12\) in absolute value by using a graphing calculator or computer software to estimate the maximum value. We begin by estimating the number of subintervals we are likely to need. To get two decimal places of accuracy, we will certainly need \(E(\Delta x)\lt 0.005\text{,}\) but taking a cue from our earlier example, let's require \(E(\Delta x)\lt 0.001\text{:}\)

\begin{align*} {1\over180}(12){1\over n^4} \amp \lt 0.001\\ {200\over3}\amp \lt n^4\\ 2.86\approx\root[4] \of {200\over3}\amp \lt n \end{align*}

So we try \(n=4\text{,}\) since we need an even number of subintervals. Then the error bound is \(\ds12/180/4^4\lt 0.0003\) and the approximation is

\begin{equation*} (f(0)+4f(1/4)+2f(1/2)+4f(3/4)+f(1)){1\over3\cdot4} \approx 0.746855\text{.} \end{equation*}

So the true value of the integral is between \(0.746855-0.0003=0.746555\) and \(0.746855+0.0003=0.7471555\text{,}\) both of which round to \(0.75\text{.}\) This is a great approximation of the integral considering it only requires 4 evaluations of the integrand function! Remember that significantly more terms were required for the Trapezoid Rule approximation.

Exercises for Section 2.6.

Approximate the following integrals by computing the Trapezoid and Simpson approximations using 4 subintervals, and compute the error bound for each. (Finding the maximum values of the second and fourth derivatives can be challenging for some of these; you may use a graphing calculator or computer software to estimate the maximum values.)

  1. \(\ds\int_1^3 x\,dx\)

    Answer
    T,S: \(4\pm0\)
    Solution

    Let \(f(x) = x\text{.}\) We will first approximate the integral using the Trapezoid rule with 4 subintervals. Take

    \begin{equation*} a = 1,\ b = 3, \ \Delta x = \frac{1}{2}\text{.} \end{equation*}

    Our approximation is

    \begin{equation*} \begin{split} \int_1^3 x \,dx \amp \approx \frac{1}{4} \bigl(f(1) + 2 f\left(\frac{3}{2}\right) + 2 f(2) + 2 f\left(\frac{5}{2}\right) + f(3)\bigr)\\ \amp = \frac{1}{4} \bigl(1+ 3 + 4 + 5 + 3\bigr)\\ \amp = \frac{16}{4}\\ \amp = 4. \end{split} \end{equation*}

    Since \(f''(x) = 0\text{,}\) we in fact have that the error in this approximation is zero; that is, this is the exact solution. Using Simpson's Rule, we approximate

    \begin{equation*} \begin{split} \int_1^3 x \,dx \amp \approx \frac{1}{6} \bigl(f(1) + 4 f\left(\frac{3}{2}\right) + 2 f(2) + 4f\left(\frac{5}{2}\right) + f(3)\bigr)\\ \amp = \frac{1}{6} \bigl(1+ 6 + 4 + 10 + 3\bigr)\\ \amp = \frac{24}{6}\\ \amp = 4. \end{split} \end{equation*}

    Since \(f^{(4)} = 0\text{,}\) we again find that the error in this approximation is zero. Therefore, both the Trapezoid rule and Simpson's rule give the exact solution in this case:

    \begin{equation*} \int_{1^3} x \,dx = 4\text{.} \end{equation*}
  2. \(\ds\int_0^3 x^2\,dx\)

    Answer
    T: \(9.28125\pm0.28125\text{;}\) S: \(9\pm0\)
    Solution

    Here, we have

    \begin{equation*} f(x) = x^2, \ a = 0, \ b= 3, \ \Delta x = \frac{3}{4}\text{.} \end{equation*}

    Using the Trapezoid rule, our approximation is

    \begin{equation*} \begin{split} \int_0^3 x^2 \,dx \amp \approx \frac{3}{8} \bigl( f(0) + 2 f\left(\frac{3}{4}\right) + 2 f\left(\frac{3}{2}\right) + 2 f\left(\frac{9}{4}\right) + f(3)\bigr)\\ \amp = \frac{3}{8}\bigl( 0 + 2 \frac{9}{16} + 2 \frac{9}{4} + 2 \frac{81}{16} + 9\bigr)\\ \amp = \frac{297}{32} \end{split} \end{equation*}

    The error in this approximation is bounded by:

    \begin{equation*} E\left(\frac{3}{4}\right) = \frac{9}{64} M\text{,} \end{equation*}

    where \(|f''(x)| \leq M\) on \([0,3]\text{.}\) Since

    \begin{equation*} f''(x) = 2\text{,} \end{equation*}

    we must have \(M= 2\text{.}\) Therefore, the Trapezoid approximation is

    \begin{equation*} \int_0^3 x^2\,dx = \frac{297}{32} \pm \frac{18}{64} \approx 9.28125 \pm 0.28125\text{.} \end{equation*}

    Using Simpson's rule, we find:

    \begin{equation*} \begin{split} \int_0^3 x^2 \,dx \amp \approx \frac{1}{4} \bigl( f(0) + 4 f\left(\frac{3}{4}\right) + 2 f\left(\frac{3}{2}\right) + 4 f\left(\frac{9}{4}\right) + f(3)\bigr)\\ \amp = \frac{1}{4}\bigl( 0 + 4 \frac{9}{16} + 2 \frac{9}{4} + 4 \frac{81}{16} + 9\bigr)\\ \amp = 9 \end{split} \end{equation*}

    Since \(|f^{(4)}| = 0\text{,}\) we see that Simpson's rule gives the exact solution in this case.

  3. \(\ds\int_2^4 x^3\,dx\)

    Answer
    T: \(60.75\pm1\text{;}\) S: \(60\pm0\)
    Solution

    Here, we have

    \begin{equation*} f(x) = x^3, \ a = 2, \ b= 4, \ \Delta x = \frac{1}{2}\text{.} \end{equation*}

    We first approximate the integral using the Trapezoid rule:

    \begin{equation*} \begin{split} \int_2^4 x^3\,dx \amp \approx \frac{1}{4} \bigl( f(2) + 2 f\left(\frac{5}{2}\right) + 2 f(3) + 2f\left(\frac{7}{2}\right) + f(4) \bigr)\\ \amp = \frac{1}{4} \bigl(2^3 + 2 \left(\frac{5}{2}\right)^3 + 2 (3^3) + 2\left(\frac{7}{2}\right)^3 + 4^3 \\ \amp = \frac{243}{4}. \end{split} \end{equation*}

    The error in this approximation can be bounded by:

    \begin{equation*} E\left(\frac{1}{2}\right) = \frac{8}{12(16)} M = \frac{M}{24}\text{,} \end{equation*}

    where \(|f''(x)| \leq M\) on \([2,4]\text{.}\) Since

    \begin{equation*} f''(x) = 6x\text{,} \end{equation*}

    we see that \(|f''(x)| \leq 6(4) = 24\) on this interval. Hence, we take \(M=24\text{.}\) Therefore, the Trapezoid rule gives

    \begin{equation*} \int_2^4 x^3\,dx = \frac{243}{4} \pm 1\text{.} \end{equation*}

    If we instead use Simpson's rule, we get:

    \begin{equation*} \begin{split} \int_2^4 x^3\,dx \amp \approx \frac{1}{6} \bigl( f(2) +4 f\left(\frac{5}{2}\right) +2 f(3) + 4f\left(\frac{7}{2}\right) + f(4) \bigr)\\ \amp = \frac{1}{4} \bigl(2^3 + 4 \left(\frac{5}{2}\right)^3 + 2 (3^3) + 4\left(\frac{7}{2}\right)^3 + 4^3 \\ \amp = 60 \end{split} \end{equation*}

    Since \(|f^{(4)}| = 0\text{,}\) this approximation is actually the exact solution. Therefore, Simpson's rule tells us that

    \begin{equation*} \int_2^4 x^3\,dx = 60\text{.} \end{equation*}
  4. \(\ds\int_1^3 {1\over x}\,dx\)

    Answer
    T: \(1.1167\pm 0.0833\text{;}\) S: \(1.1000\pm 0.0167\)
    Solution

    Let

    \begin{equation*} f(x) = \frac{1}{x}, \ a = 1, \ b = 3, \ \Delta x = \frac{1}{2}\text{.} \end{equation*}

    We first approximate the integral using trapezoids. This gives

    \begin{equation*} \begin{split} \int_1^3 \frac{1}{x}\,dx \amp \approx \frac{1}{4}\bigl(f(1) + 2f\left(\frac{3}{2}\right) + 2 f(2) + 2 f\left(\frac{5}{2}\right) + f(3)\bigr)\\ \amp = \frac{1}{4} \bigl(1 + 2 \frac{2}{3} + \frac{2}{2} + 2\frac{2}{5} + \frac{1}{3}\bigr)\\ \amp = \frac{67}{60} \end{split} \end{equation*}

    To compute a bound on the error to this approximation, we differentiate:

    \begin{equation*} f'(x) = -\frac{1}{x^2}, \text{ and } f''(x) = \frac{2}{x^3}\text{.} \end{equation*}

    Therefore, on the interval \([1,3]\text{,}\) we see that

    \begin{equation*} |f''(x)| \leq 2\text{.} \end{equation*}

    Hence,

    \begin{equation*} E\left(\frac{1}{2}\right) = \frac{2^3}{12(16)} (2) = \frac{1}{12}\text{.} \end{equation*}

    Therefore, the Trapezoid approximation is

    \begin{equation*} \int_1^3 \frac{1}{x}\,dx = \frac{67}{70} \pm \frac{1}{12}\text{.} \end{equation*}

    Now using Simpson's rule, we find

    \begin{equation*} \begin{split} \int_1^3 \frac{1}{x}\,dx \amp \approx \frac{1}{6}\bigl(f(1) + 4f\left(\frac{3}{2}\right) + 2 f(2) + 4 f\left(\frac{5}{2}\right) + f(3)\bigr)\\ \amp = \frac{1}{6} \bigl(1 + 4 \frac{2}{3} + \frac{2}{2} + 4\frac{2}{5} + \frac{1}{3}\bigr)\\ \amp = \frac{11}{10} \end{split} \end{equation*}

    To compute a bound on the error to this approximation, we differentiate:

    \begin{equation*} f^{(3)}(x) = -\frac{6}{x^4}, \text{ and } f^{(4)}(x) = \frac{24}{x^5}\text{.} \end{equation*}

    Therefore, on the interval \([1,3]\text{,}\) we see that

    \begin{equation*} |f^{(4)}(x)| \leq 24\text{.} \end{equation*}

    Hence,

    \begin{equation*} E\left(\frac{1}{2}\right) = \frac{2^5}{180(4^4)} 24 = \frac{1}{60} \end{equation*}

    Therefore, the Simpson's approximation is

    \begin{equation*} \int_1^3 \frac{1}{x}\,dx = \frac{11}{10} \pm \frac{1}{60}\text{.} \end{equation*}

    Note that the exact solution is

    \begin{equation*} \int_1^3 \frac{1}{x}\,dx = \log(3) \approx 1.0986\text{.} \end{equation*}
  5. \(\ds\int_1^2 {1\over 1+x^2}\,dx\)

    Answer
    T: \(0.3235\pm 0.0026\text{;}\) S: \(0.3217\pm 0.000065\)
    Solution

    Let \(f(x) = \frac{1}{x^2+1}\text{.}\) First approximate the integral using the Trapezoid Rule with 4 subintervals. That is,

    \begin{equation*} a = 1,\ b= 2, \ \Delta x = \frac{1}{4}\text{.} \end{equation*}

    Our approximation is thus

    \begin{equation*} \begin{split} \int_1^2 \frac{1}{1+x^2} \,dx \amp \approx \frac{1}{8}\left[ f(1) + 2f\left(\frac{5}{4}\right) + 2f\left(\frac{3}{2}\right) + 2f\left(\frac{7}{4}\right) + f(2)\right] \\[1ex] \amp = \frac{1}{8} \left[\frac{1}{2} + 2\frac{16}{41} + 2\frac{4}{13} + 2\frac{16}{65} + \frac{1}{5}\right] \\[1ex] \amp \approx 0.3252. \end{split} \end{equation*}

    The error in this approximation can be bounded by

    \begin{equation*} E\left(\frac{1}{4}\right) = \frac{1}{12(4^2)} M\text{,} \end{equation*}

    where \(|f''(x)| \leq M\) for all \(x \in [1,2]\text{.}\) We calculate

    \begin{equation*} f'(x) = \frac{-2x}{(1+x^2)^2}, \text{ and } f''(x) = \frac{8x^2}{(1+x^2)^3} - \frac{2}{(1+x^2)^2}\text{.} \end{equation*}

    On the closed interval \([1,2]\) the function \(f''\) is monotonically decreasing. Therefore the local maximum occurs at \(x=1\text{.}\) A suitable choice for \(M\) is thus

    \begin{equation*} M = |f''(1)| = \frac{1}{2} \implies E\left(\frac{1}{4}\right) \approx 0.0026\text{.} \end{equation*}

    And so our Trapezoid approximation is

    \begin{equation*} \int_1^2 \frac{1}{x^2+1}\,dx \approx 0.32352 \pm 0.0026\text{.} \end{equation*}

    The exact solution is

    \begin{equation*} \int_1^2 \frac{1}{x^2+1}\,dx=0.32175\text{,} \end{equation*}

    which is within the range found above.

    Using Simpson's Rule, our approximation becomes

    \begin{equation*} \begin{split} \int_1^2 \frac{1}{1+x^2} \,dx \amp \approx \frac{1}{12}\left[ f(1) + 4f\left(\frac{5}{4}\right) + 2f\left(\frac{3}{2}\right) + 4f\left(\frac{7}{4}\right) + f(2)\right] \\[1ex] \amp = \frac{1}{12} \left[\frac{1}{2} + 4\frac{16}{41} + 2\frac{4}{13} + 4\frac{16}{65} + \frac{1}{5}\right] \\[1ex] \amp \approx 0.32175. \end{split} \end{equation*}

    The error is now bounded by

    \begin{equation*} E\left(\frac{1}{4}\right) = \frac{1}{180(4^4)} M\text{,} \end{equation*}

    where \(|f^{(4)}(x)| \leq M\) for all \(x\in [1,2]\text{.}\) We calculate

    \begin{equation*} f^{(3)}(x) = \frac{24x}{(1+x^2)^3} - \frac{48x^3}{(1+x^2)^4}, \text{ and } f^{(4)}(x)= -\frac{288 x^2}{(x^2 + 1)^4} + \frac{24}{(x^2 + 1)^3} + \frac{384 x^4}{(x^2 + 1)^5}\text{.} \end{equation*}

    From the graph above, we see that on the closed interval \([1,2]\text{,}\) the function \(f^{(4)}\) attains a maximum of \(3/8\) at \(x=\sqrt{3}\text{,}\) and a minimum of \(-3\) at \(x=1\text{.}\) Since \(|f^{(4)}(1)| \geq |f^{(4)}(x)|\) for all \(x \in [1,2]\text{,}\) we take

    \begin{equation*} M = |f^{(4)}(1)| = 3 \implies E\left(\frac{1}{4}\right) \approx 0.000065\text{.} \end{equation*}

    Our Simpson's approximation is thus

    \begin{equation*} \int_1^2 \frac{1}{x^2+1}\,dx \approx 0.32175 \pm 0.000065\text{.} \end{equation*}
  6. \(\ds\int_0^1 x\sqrt{1+x}\,dx\)

    Answer
    T: \(0.6478\pm 0.0052\text{;}\) S: \(0.6438\pm 0.000033\)
    Solution

    We take

    \begin{equation*} f(x) = x\sqrt{1+x}, \ a = 0, \ b= 1, \ \Delta x = \frac{1}{4}\text{.} \end{equation*}

    Our Trapezoid approximation is:

    \begin{equation*} \begin{split} \int_0^1 x\sqrt{1+x}\,dx \amp \approx \frac{1}{8}\bigl[f(0) +2 f\left(\frac{1}{4}\right) + 2 f\left(\frac{1}{2}\right) + 2f\left(\frac{3}{4}\right) + f(1) \bigr]\\ \amp = \frac{1}{8}\left[ 0 + 2\frac{\sqrt{5}}{8} + 2 \frac{\sqrt{6}}{4} + 2 \frac{3\sqrt{7}}{8} + \sqrt{2} \right]\\ \amp \approx 0.647786 \end{split} \end{equation*}

    To find the bound for the error in this approximation, we first compute

    \begin{equation*} f'(x) = \frac{3x+2}{2\sqrt{1+x}}, \text{ and } f''(x) = \frac{3x+4}{4(1+x)^{3/2}}\text{.} \end{equation*}

    We notice that \(f''(x)\) is a decreasing function on \([0,1]\text{.}\) Therefore,

    \begin{equation*} |f''(x)| \leq |f''(0)| = 1\text{.} \end{equation*}

    Hence, the error in this approximation is bounded by

    \begin{equation*} E\left(\frac{1}{4}\right) = \frac{1}{12(16)} (1) = \frac{1}{192}\text{.} \end{equation*}

    Therefore, using the Trapezoid rule, we find that

    \begin{equation*} \int_0^1 x\sqrt{1+x}\,dx = 0.6478 \pm 0.0053\text{.} \end{equation*}

    If we instead use Simpson's rule, we get

    \begin{equation*} \begin{split} \int_0^1 x\sqrt{1+x}\,dx \amp \approx \frac{1}{12}\left[f(0) +4 f\left(\frac{1}{4}\right) + 2 f\left(\frac{1}{2}\right) + 4 f\left(\frac{3}{4}\right) + f(1) \right]\\ \amp = \frac{1}{12}\left[ 0 + 4\frac{\sqrt{5}}{8} + 2 \frac{\sqrt{6}}{4} + 4 \frac{3\sqrt{7}}{8} + \sqrt{2} \right]\\ \amp \approx 0.6438016 \end{split} \end{equation*}

    We now compute

    \begin{equation*} f^{(3)}(x) = -\frac{3(x+2)}{8(1+x)^{5/2}} , \text{ and } f^{(4)}(x) = \frac{3(3x+8)}{16(x+1)^{7/2}}\text{.} \end{equation*}

    Therefore, \(|f^{(4)}(x)| \leq |f^{(4)}(0)| = 3\text{.}\) So the error in this approximation is bounded by

    \begin{equation*} E\left(\frac{1}{4}\right) = \frac{1}{180(4^4)}(3) = \frac{1}{15360} \lt 0.000066\text{.} \end{equation*}

    Hence, using Simpson's rule, we find that

    \begin{equation*} \int_0^1 x\sqrt{1+x}\,dx = 0.643802 \pm 0.000066\text{.} \end{equation*}
  7. \(\ds\int_1^5 {x\over 1+x}\,dx\)

    Answer
    T: \(2.8833\pm 0.0834\text{;}\) S: \(2.9 \pm 0.051\)
    Solution

    Let \(f(x) = \frac{x}{1+x}\text{.}\) First approximate the integral using the Trapezoid Rule with 4 subintervals. That is,

    \begin{equation*} a = 1,\ b= 5, \ \Delta x = 1\text{.} \end{equation*}

    Our Trapezoid approximation is:

    \begin{equation*} \begin{split} \int_1^5 \frac{x}{1+x}\,dx \amp \approx \frac{1}{2}\left[f(1) +2 f\left(2\right) + 2 f\left(3\right) + 2f\left(4\right) + f(5) \right]\\ \amp = \frac{1}{2}\left[ \frac{1}{2} + 2 \frac{2}{3} + 2 \frac{3}{4} + 2\frac{4}{5} + \frac{5}{6}\right]\\ \amp =\frac{173}{60} \end{split} \end{equation*}

    To determine the error bound in this approximation, we need to find a bound on \(f''(x)\) for \(x \in [1,5]\text{.}\) We compute

    \begin{equation*} f'(x) = \frac{1}{(1+x)^2}, \text{ and } f''(x) = \frac{-2}{(1+x)^3}\text{.} \end{equation*}

    We consider the graph of \(f''(x)\text{:}\)

    We notice that on this interval

    \begin{equation*} |f''(x)| \leq |f''(1)| = \frac{2}{2^3} = \frac{1}{4}\text{.} \end{equation*}

    Therefore, we must have that

    \begin{equation*} E(1) = \frac{5^3}{12(16)} \frac{1}{4} = \frac{125}{768}\text{.} \end{equation*}

    All together, the Trapezoid rule gives

    \begin{equation*} \int_1^5 \frac{x}{1+x}\,dx = \frac{173}{60} \pm \frac{125}{768}\text{.} \end{equation*}

    If we instead use Simpson's rule, we would get:

    \begin{equation*} \begin{split} \int_1^5 \frac{x}{1+x}\,dx \amp \approx \frac{1}{3}\bigl[f(1) +4 f\left(2\right) + 2 f\left(3\right) + 4f\left(4\right) + f(5) \bigr]\\ \amp = \frac{1}{3}\left[ \frac{1}{2} + 4 \frac{2}{3} + 2 \frac{3}{4} + 4\frac{4}{5} + \frac{5}{6}\right]\\ \amp =\frac{29}{10} \end{split} \end{equation*}

    We now compute

    \begin{equation*} f^{(3)}(x) = \frac{6}{(1+x)^4}, \text{ and } f^{(4)}(x) = -\frac{24}{(1+x)^5}\text{.} \end{equation*}

    Consider the graph of \(f^{(4)}(x)\text{:}\)

    From this graph, we see that \(|f^{(4)}(x)| \leq |f^{(4)}(1)| = \frac{3}{4}\text{.}\) And the associated error bound is

    \begin{equation*} E(1) = \frac{5^5}{180(4^4)} \frac{3}{4} \lt 0.051\text{.} \end{equation*}

    Hence, Simpson's rule tells us that

    \begin{equation*} \int_1^5 \frac{x}{1+x}\,dx = 2.9 \pm 0.051\text{.} \end{equation*}
  8. \(\ds\int_0^1 \sqrt{x^3+1}\,dx\)

    Answer
    T: \(1.1170\pm 0.0077\text{;}\) S: \(1.1114\pm 0.0002\)
    Solution

    We take

    \begin{equation*} f(x) = \sqrt{x^3+1}, \ a = 0, \ b= 1, \ \Delta x = \frac{1}{4}\text{.} \end{equation*}

    Our Trapezoid approximation is:

    \begin{equation*} \begin{split} \int_0^1 \sqrt{x^3+1} \,dx \amp \approx \frac{1}{8}\left[f(0) +2 f\left(\frac{1}{4}\right) + 2 f\left(\frac{1}{2}\right) + 2f\left(\frac{3}{4}\right) + f(1) \right]\\ \amp = \frac{1}{8}\left[1 + 2\frac{\sqrt{65}}{8} + 2\frac{3}{2\sqrt{2}} + 2\frac{\sqrt{91}}{8} + \sqrt{2}\right]\\ \amp \approx 1.11699 \end{split} \end{equation*}

    To find a bound on the error in this approximation, we need to analyze \(f''(x)\) on \([0,1]\text{.}\) We compute:

    \begin{equation*} f'(x) = \frac{3x^2}{2\sqrt{x^3+1}}, \text{ and } f''(x) = \frac{3x(x^3+4)}{4(x^3+1)^{3/2}}\text{.} \end{equation*}

    The plot of \(f''(x)\) is shown below:

    Hence, we see that \(|f''(x)| \lt 1.5\) for all \(x \in [0,1]\text{.}\) Therefore, we have

    \begin{equation*} E\left(\frac{1}{4}\right) \lt \frac{1}{12(16)} (1.5) = 0.0078125\text{.} \end{equation*}

    (Note that we could find a slightly better bound by finding the exact maximum of \(f''(x)\) on \([0,1]\text{.}\)) Thus, the Trapezoid rule gives

    \begin{equation*} \int_0^1 \sqrt{1+x^3}\,dx = 1.11699 \pm 0.0078125\text{.} \end{equation*}

    If we instead use Simpson's rule, we get:

    \begin{equation*} \begin{split} \int_0^1 \sqrt{x^3+1} \,dx \amp \approx \frac{1}{12}\left[f(0) +4 f\left(\frac{1}{4}\right) + 2 f\left(\frac{1}{2}\right) + 4f\left(\frac{3}{4}\right) + f(1) \right]\\ \amp = \frac{1}{12}\left[1 + 4\frac{\sqrt{65}}{8} + 2\frac{3}{2\sqrt{2}} + 4\frac{\sqrt{91}}{8} + \sqrt{2}\right]\\ \amp \approx 1.11144 \end{split} \end{equation*}

    We now compute

    \begin{equation*} f^{(3)}(x) =-\frac{3(x^6+20x^3-8)}{8(1+x^3)^{5/2}} , \text{ and } f^{(4)}(x) =\frac{9x^2(x^6+56x^3-80)}{16(x^3+1)^{7/2}}\text{.} \end{equation*}

    We consider the plot of \(f^{(4)}\) below:

    This shows that \(|f^{(4)} (x)| \lt 7.1\) for \(x \in [0,1]\text{.}\) Therefore, an error bound is

    \begin{equation*} E\left(\frac{1}{4}\right) \lt \frac{1}{180(4^4)} 7.1 \lt 0.000155\text{.} \end{equation*}

    Hence, Simpson's rule gives

    \begin{equation*} \int_0^1 \sqrt{1+x^3}\,dx = 1.11144 \pm 0.000155\text{.} \end{equation*}
  9. \(\ds\int_0^1 \sqrt{x^4+1}\,dx\)

    Answer
    T: \(1.097\pm 0.0147\text{;}\) S: \(1.089\pm 0.0003\)
    Solution

    We take

    \begin{equation*} f(x) = \sqrt{x^4+1}, \ a = 0, \ b= 1, \ \Delta x = \frac{1}{4}\text{.} \end{equation*}

    Our Trapezoid approximation is:

    \begin{equation*} \begin{split} \int_0^1 \sqrt{x^4+1} \,dx \amp \approx \frac{1}{8}\left[f(0) +2 f\left(\frac{1}{4}\right) + 2 f\left(\frac{1}{2}\right) + 2f\left(\frac{3}{4}\right) + f(1) \right]\\ \amp \approx 1.097 \end{split} \end{equation*}

    We now compute

    \begin{equation*} f'(x) = \frac{2x^3}{\sqrt{x^4+1}} \text{ and } f''(x) = \frac{2x^2(x^4+3}{(x^4+1)^{3/2}}\text{.} \end{equation*}

    Instead of finding the exact maximimum of \(|f''(x)|\) on \([0,1]\text{,}\) we will plot the graph of \(f''(x)\) to estimate a bound:

    Thus, \(|f''(x)| \lt 2.9\) on \([0,1]\text{.}\) Hence, the error in the Trapezoid approximation can be bounded by

    \begin{equation*} E\left(\frac{1}{4}\right) \lt \frac{1}{12(16)}(2.9) \lt 0.0152\text{.} \end{equation*}

    (Note that we could find a tighter bound by finding the exact maximun of \(f''(x)\)). Therefore, using the Trapezoid rule, we find

    \begin{equation*} \int_0^1 \sqrt{x^4+1}\,dx = 1.097 \pm 0.0152\text{.} \end{equation*}

    If we instead use Simpson's rule, we find that:

    \begin{equation*} \begin{split} \int_0^1 \sqrt{x^3+1} \,dx \amp \approx \frac{1}{12}\left[f(0) +4 f\left(\frac{1}{4}\right) + 2 f\left(\frac{1}{2}\right) + 4f\left(\frac{3}{4}\right) + f(1) \right]\\ \amp \approx 1.089, \end{split} \end{equation*}

    We now compute

    \begin{equation*} f^{(3)}(x) = -\frac{12x(x^4-1)}{(1+x^4)^{5/2}}, \text{ and } f^{(4)}(x) = \frac{12(5x^8-14x^4+1)}{(x^4+1)^{7/2}}\text{.} \end{equation*}

    We plot \(f^{(4)}(x)\) below:

    From the graph, we see that \(|f^{(4)}(x)| \lt 14.5\) on \([0,1]\text{.}\) Therefore, an error bound is

    \begin{equation*} E\left(\frac{1}{4}\right) \lt \frac{1}{180(4^4)} (14.5) \lt 0.00032\text{.} \end{equation*}

    Hence, Simpson's rule tells us that

    \begin{equation*} \int_0^1 \sqrt{x^4+1}\,dx = 1.089 \pm 0.00032\text{.} \end{equation*}
  10. \(\ds\int_1^4 \sqrt{1+1/x}\,dx\)

    Answer
    T: \(3.63\pm 0.087\text{;}\) S: \(3.62\pm 0.032\)

Using Simpson's Rule on a parabola \(f(x)\text{,}\) even with just two subintervals, gives the exact value of the integral, because the parabolas used to approximate \(f\) will be \(f\) itself. Remarkably, Simpson's Rule also computes the integral of a cubic function \(f(x)=ax^3+bx^2+cx+d\) exactly. Show this is true by showing that

\begin{equation*} \int_{x_0}^{x_2} f(x)\,dx={x_2-x_0\over3\cdot2}(f(x_0)+4f((x_0+x_2)/2)+f(x_2))\text{.} \end{equation*}

This does require a bit of messy algebra, so you may prefer to use Sage.

Answer
\(\ds \frac{x_2-x_0}{3 \cdot 2} \left[f(x_0) + 4 f\left(\frac{x_0+x_2}{2}\right) + f(x_2)\right]\)
Solution

Let \(f(x) = ax^3+bx^2+cx+d\text{.}\) To approximate

\begin{equation*} \int_{x_0}^{x_2} f(x)\,dx \end{equation*}

using Simpson's rule and \(2\) subintervals, we take

\begin{equation*} \Delta x = \frac{x_2 - x_0}{2}\text{.} \end{equation*}

Then we have the following approximation:

\begin{equation*} \begin{split} \int_{x_0}^{x_2} f(x)\,dx \amp \approx \frac{\Delta x}{3}\left[f(x_0) + 4f(x_1) + f(x_2)\right]\\ \amp = \frac{x_2-x_0}{3 \cdot 2} \left[f(x_0) + 4 f\left(\frac{x_0+x_2}{2}\right) + f(x_2)\right] \end{split} \end{equation*}

where we have written

\begin{equation*} x_1 = x_0 + \Delta x = x_0 + \frac{x_2-x_0}{2} = \frac{x_0+x_2}{2}\text{.} \end{equation*}

The error associated with this approximation is given by

\begin{equation*} E(\Delta x) = \frac{(x_2-x_0)^5}{180(2^4)} M\text{,} \end{equation*}

where \(|f^{(4)}| \leq M\) for all \(x\in [x_0,x_2]\text{.}\) Since \(f(x)\) is a cubic polynomial, we must have that \(f^{(4)} = 0\text{.}\) In other words, the error in this approximation is zero and so it is exact:

\begin{equation*} \int_{x_0}^{x_2} f(x)\,dx = \frac{x_2-x_0}{3 \cdot 2} \left[f(x_0) + 4 f\left(\frac{x_0+x_2}{2}\right) + f(x_2)\right]\text{.} \end{equation*}