# 8.7 Numerical Integration

The Fundamental Theorem of Calculus gives a concrete technique for finding the exact value of a definite integral. That technique is based on computing antiderivatives. Despite the power of this theorem, there are still situations where we must approximate the value of the definite integral instead of finding its exact value. The first situation we explore is where we cannot compute an antiderivative of the integrand. The second case is when we actually do not know the integrand, but only its value when evaluated at certain points.

An elementary function is any function that is a combination of polynomials, $n^{\text{th}}$ roots, rational, exponential, logarithmic and trigonometric functions and their inverses. We can compute the derivative of any elementary function, but there are many elementary functions of which we cannot compute an antiderivative. For example, the following functions do not have antiderivatives that we can express with elementary functions:

 $e^{-x^{2}},\quad\sin(x^{3})\quad\text{and}\quad\frac{\sin x}{x}.$

The simplest way to refer to the antiderivatives of $e^{-x^{2}}$ is to simply write $\displaystyle\int e^{-x^{2}}\operatorname{d}\!x$.

margin: Figure 8.7.1: Graphically representing three definite integrals that cannot be evaluated using antiderivatives. Λ

This section outlines three common methods of approximating the value of definite integrals. We describe each as a systematic method of approximating area under a curve. By approximating this area accurately, we find an accurate approximation of the corresponding definite integral.

We will apply the methods we learn in this section to the following definite integrals:

 $\int_{0}^{1}e^{-x^{2}}\operatorname{d}\!x,\quad\int_{-\frac{\pi}{4}}^{\frac{% \pi}{2}}\sin(x^{3})\operatorname{d}\!x,\quad\text{and}\quad\int_{0.5}^{4\pi}% \frac{\sin(x)}{x}\operatorname{d}\!x,$

as pictured in Figure 8.7.1.

## The Left and Right Hand Rule Methods

In Section 5.3 we addressed the problem of evaluating definite integrals by approximating the area under the curve using rectangles. We revisit those ideas here before introducing other methods of approximating definite integrals.

We start with a review of notation. Let $f$ be a continuous function on the interval $[a,b]$. We wish to approximate $\displaystyle\int_{a}^{b}f(x)\operatorname{d}\!x$. We partition $[a,b]$ into $n$ equally spaced subintervals, each of length $\displaystyle\Delta x=\frac{b-a}{n}$. The endpoints of these subintervals are labeled as

 $x_{0}=a,\ x_{1}=a+\Delta x,\ x_{2}=a+2\Delta x,\ \dotsc,\ x_{i}=a+i\Delta x,\ % \dotsc,\ x_{n}=b.$

Section 5.3 showed that to use the Left Hand Rule we use the summation $\displaystyle\sum_{i=1}^{n}f(x_{i-1})\Delta x$ and to use the Right Hand Rule we use $\displaystyle\sum_{i=1}^{n}f(x_{i})\Delta x$. We review the use of these rules in the context of examples.

###### Example 8.7.1 Approximating definite integrals with rectangles

Approximate $\displaystyle\int_{0}^{1}e^{-x^{2}}\operatorname{d}\!x$ using the Left and Right Hand Rules with 5 equally spaced subintervals.

SolutionWe begin by partitioning the interval $[0,1]$ into 5 equally spaced intervals. We have $\Delta x=\frac{1-0}{5}=1/5=0.2$, so

 $x_{0}=0,\ x_{1}=0.2,\ x_{2}=0.4,\ x_{3}=0.6,\ x_{4}=0.8,\text{ and }x_{5}=1.$
margin: Figure 8.7.2: Approximating $\displaystyle\int_{0}^{1}e^{-x^{2}}\operatorname{d}\!x$ in Example 8.7.1 using (top) the left hand rule and (bottom) the right hand rule. Λ

Using the Left Hand Rule, we have:

 $\displaystyle\sum_{i=1}^{n}f(x_{i-1})\Delta x$ $\displaystyle=\bigl{(}f(x_{0})+f(x_{1})+f(x_{2})+f(x_{3})+f(x_{4})\bigr{)}\Delta x$ $\displaystyle=\bigl{(}f(0)+f(0.2)+f(0.4)+f(0.6)+f(0.8)\bigr{)}\Delta x$ $\displaystyle\approx\bigl{(}1+0.961+0.852+0.698+0.527\bigr{)}(0.2)$ $\displaystyle\approx 0.808.$

Using the Right Hand Rule, we have:

 $\displaystyle\sum_{i=1}^{n}f(x_{i})\Delta x$ $\displaystyle=\bigl{(}f(x_{1})+f(x_{2})+f(x_{3})+f(x_{4})+f(x_{5})\bigr{)}\Delta x$ $\displaystyle=\bigl{(}f(0.2)+f(0.4)+f(0.6)+f(0.8)+f(1)\bigr{)}\Delta x$ $\displaystyle\approx\bigl{(}0.961+0.852+0.698+0.527+0.368\bigr{)}(0.2)$ $\displaystyle\approx 0.681.$

Figure 8.7.2 shows the rectangles used in each method to approximate the definite integral. These graphs show that in this particular case, the Left Hand Rule is an over approximation and the Right Hand Rule is an under approximation. To get a better approximation, we could use more rectangles, as we did in Section 5.3. We could also average the Left and Right Hand Rule results together, giving

 $\frac{0.808+0.681}{2}=0.7445.$

The actual answer, accurate to 4 places after the decimal, is 0.7468, showing our average is a good approximation.

margin: $x_{i}$ Exact Approx. $\sin(x_{i}^{3})$ $x_{0}$ $-\pi/4\phantom{0}$ $-0.785$ $-0.466$ $x_{1}$ $-7\pi/40$ $-0.550$ $-0.165$ $x_{2}$ $-\pi/10$ $-0.314$ $-0.031$ $x_{3}$ $-\pi/40$ $-0.0785$ $\phantom{-}0$ $x_{4}$ $\pi/20$ $\phantom{-}0.157$ $\phantom{-}0.004$ $x_{5}$ $\pi/8\phantom{0}$ $\phantom{-}0.393$ $\phantom{-}0.061$ $x_{6}$ $\pi/5\phantom{0}$ $\phantom{-}0.628$ $\phantom{-}0.246$ $x_{7}$ $11\pi/40$ $\phantom{-}0.864$ $\phantom{-}0.601$ $x_{8}$ $7\pi/20$ $\phantom{-}1.10$ $\phantom{-}0.971$ $x_{9}$ $17\pi/40$ $\phantom{-}1.34$ $\phantom{-}0.690$ $x_{10}$ $\pi/2\phantom{0}$ $\phantom{-}1.57$ $-0.670$ Figure 8.7.3: Table of values used to approximate $\displaystyle\int_{-\frac{\pi}{4}}^{\frac{\pi}{2}}\sin(x^{3})\operatorname{d}\!x$ in Example 8.7.2. Λ
###### Example 8.7.2 Approximating definite integrals with rectangles

Approximate $\displaystyle\int_{-\frac{\pi}{4}}^{\frac{\pi}{2}}\sin(x^{3})\operatorname{d}\!x$ using the Left and Right Hand Rules with 10 equally spaced subintervals.

SolutionWe begin by finding $\Delta x$:

 $\frac{b-a}{n}=\frac{\pi/2-(-\pi/4)}{10}=\frac{3\pi}{40}\approx 0.236.$

It is useful to write out the endpoints of the subintervals in a table; in Figure 8.7.3, we give the exact values of the endpoints, their decimal approximations, and decimal approximations of $\sin(x^{3})$ evaluated at these points.

margin: Figure 8.7.4: Approximating$\displaystyle\int_{-\frac{\pi}{4}}^{\frac{\pi}{2}}\sin(x^{3})\operatorname{d}\!x$ in Example 8.7.2 using (top) the left hand rule and (bottom) the right hand rule. Λ

Once this table is created, it is straightforward to approximate the definite integral using the Left and Right Hand Rules. (Note: the table itself is easy to create, especially with a standard spreadsheet program on a computer. The last two columns are all that are needed.) The Left Hand Rule sums the first 10 values of $\sin(x_{i}^{3})$ and multiplies the sum by $\Delta x$; the Right Hand Rule sums the last 10 values of $\sin(x_{i}^{3})$ and multiplies by $\Delta x$. Therefore we have:

 $\displaystyle\text{Left Hand Rule: }\int_{-\frac{\pi}{4}}^{\frac{\pi}{2}}\sin(% x^{3})\operatorname{d}\!x$ $\displaystyle\approx(1.91)(0.236)=0.451.$ $\displaystyle\text{Right Hand Rule: }\int_{-\frac{\pi}{4}}^{\frac{\pi}{2}}\sin% (x^{3})\operatorname{d}\!x$ $\displaystyle\approx(1.71)(0.236)=0.404.$

The average of the Left and Right Hand Rules is 0.4275. The actual answer, accurate to 3 places after the decimal, is 0.460. Our approximations were once again fairly good. The rectangles used in each approximation are shown in Figure 8.7.4. It is clear from the graphs that using more rectangles (and hence, narrower rectangles) should result in a more accurate approximation.

## The Trapezoidal Rule

In Example 8.7.1 we approximated the value of $\displaystyle\int_{0}^{1}e^{-x^{2}}\operatorname{d}\!x$ with 5 rectangles of equal width. Figure 8.7.2 showed the rectangles used in the Left and Right Hand Rules. These graphs clearly show that rectangles do not match the shape of the graph all that well, and that accurate approximations will only come by using lots of rectangles.

margin: Figure 8.7.5: Approximating $\int_{0}^{1}e^{-x^{2}}\operatorname{d}\!x$ using 5 trapezoids of equal widths. Λ

Instead of using rectangles to approximate the area, we can instead use trapezoids. In Figure 8.7.5, we show the region under $f(x)=e^{-x^{2}}$ on $[0,1]$ approximated with 5 trapezoids of equal width; the top “corners” of each trapezoid lie on the graph of $f(x)$. It is clear from this figure that these trapezoids more accurately approximate the area under $f$ and hence should give a better approximation of $\int_{0}^{1}e^{-x^{2}}\operatorname{d}\!x$. (In fact, these trapezoids seem to give a great approximation of the area.)

margin: Figure 8.7.6: The area of a trapezoid is $\frac{a+b}{2}h$. Λ

The formula for the area of a trapezoid is given in Figure 8.7.6. We approximate $\int_{0}^{1}e^{-x^{2}}\operatorname{d}\!x$ with these trapezoids in the following example.

###### Example 8.7.3 Approximating definite integrals using trapezoids

Use 5 trapezoids of equal width to approximate $\displaystyle\int_{0}^{1}e^{-x^{2}}\operatorname{d}\!x$.

SolutionTo compute the areas of the 5 trapezoids in Figure 8.7.5, it will again be useful to create a table of values as shown in Figure 8.7.7.

margin: $x_{i}$ $e^{-x_{i}^{2}}$ 0 1 0.2 0.961 0.4 0.852 0.6 0.698 0.8 0.527 1 0.368 Figure 8.7.7: A table of values of $e^{-x^{2}}$. Λ

The leftmost trapezoid has legs of length 1 and 0.961 and a height of 0.2. Thus, by our formula, the area of the leftmost trapezoid is:

 $\frac{1+0.961}{2}(0.2)=0.1961.$

Moving right, the next trapezoid has legs of length 0.961 and 0.852 and a height of 0.2. Thus its area is:

 $\frac{0.961+0.852}{2}(0.2)=0.1813.$

The sum of the areas of all 5 trapezoids is:

 $\displaystyle\frac{1+0.961}{2}(0.2)+\frac{0.961+0.852}{2}(0.2)+\frac{0.852+0.6% 98}{2}(0.2)$ $\displaystyle+\frac{0.698+0.527}{2}(0.2)+\frac{0.527+0.368}{2}(0.2)$ $\displaystyle=0.7445.$

We approximate $\displaystyle\int_{0}^{1}e^{-x^{2}}\operatorname{d}\!x\approx 0.7445$.

There are many things to observe in this example. Note how each term in the final summation was multiplied by both 1/2 and by $\Delta x=0.2$. We can factor these coefficients out, leaving a more concise summation as:

 $\frac{1}{2}(0.2)\Bigl{[}(1+0.961)+(0.961+0.852)+\\ (0.852+0.698)+(0.698+0.527)+(0.527+0.368)\Bigr{]}.$

Now notice that all numbers except for the first and the last are added twice. Therefore we can write the summation even more concisely as

 $\frac{0.2}{2}\Bigl{[}1+2(0.961+0.852+0.698+0.527)+0.368\Bigr{]}.$

This is the heart of the Trapezoidal Rule, where a definite integral $\displaystyle\int_{a}^{b}f(x)\operatorname{d}\!x$ is approximated by using trapezoids of equal widths to approximate the corresponding area under $f$. Using $n$ equally spaced subintervals with endpoints $x_{0}$, $x_{1}$, …, $x_{n}$, we again have $\displaystyle\Delta x=\frac{b-a}{n}$. Thus:

 $\displaystyle\int_{a}^{b}f(x)\operatorname{d}\!x$ $\displaystyle\approx\sum_{i=1}^{n}\frac{f(x_{i-1})+f(x_{i})}{2}\Delta x$ $\displaystyle=\frac{\Delta x}{2}\sum_{i=1}^{n}\bigl{(}f(x_{i-1})+f(x_{i})\bigr% {)}$ $\displaystyle=\frac{\Delta x}{2}\left[f(x_{0})+2\sum_{i=1}^{n-1}f(x_{i})+f(x_{% n})\right].$
###### Example 8.7.4 Using the Trapezoidal Rule

Revisit Example 8.7.2 and approximate $\displaystyle\int_{-\frac{\pi}{4}}^{\frac{\pi}{2}}\sin(x^{3})\operatorname{d}\!x$ using the Trapezoidal Rule and 10 equally spaced subintervals.

SolutionWe refer back to Figure 8.7.3 for the table of values of $\sin(x^{3})$. Recall that $\Delta x=3\pi/40\approx 0.236$. Thus we have:

 $\displaystyle\int_{-\frac{\pi}{4}}^{\frac{\pi}{2}}$ $\displaystyle\sin(x^{3})\operatorname{d}\!x$ $\displaystyle\approx\frac{0.236}{2}\Bigl{[}-0.466+2\Bigl{(}-0.165+(-0.031)+% \dotsb+0.69\Bigr{)}+(-0.67)\Bigr{]}$ $\displaystyle=0.4275.$

Notice how “quickly” the Trapezoidal Rule can be implemented once the table of values is created. This is true for all the methods explored in this section; the real work is creating a table of $x_{i}$ and $f(x_{i})$ values. Once this is completed, approximating the definite integral is not difficult. Again, using technology is wise. Spreadsheets can make quick work of these computations and make using lots of subintervals easy.

Also notice the approximations the Trapezoidal Rule gives. It is the average of the approximations given by the Left and Right Hand Rules! This effectively renders the Left and Right Hand Rules obsolete. They are useful when first learning about definite integrals, but if a real approximation is needed, one is generally better off using the Trapezoidal Rule instead of either the Left or Right Hand Rule.

We will also show that the Trapezoidal Rule makes using the Midpoint Rule obsolete as well. With much more work, it will turn out that the Midpoint Rule has only a marginal gain in accuracy. But we will include it in our results for the sake of completeness.

How can we improve on the Trapezoidal Rule, apart from using more and more trapezoids? The answer is clear once we look back and consider what we have really done so far. The Left Hand Rule is not really about using rectangles to approximate area. Instead, it approximates a function $f$ with constant functions on small subintervals and then computes the definite integral of these constant functions. The Trapezoidal Rule is really approximating a function $f$ with a linear function on a small subinterval, then computes the definite integral of this linear function. In both of these cases the definite integrals are easy to compute in geometric terms.

So we have a progression: we start by approximating $f$ with a constant function and then with a linear function. What is next? A quadratic function. By approximating the curve of a function with lots of parabolas, we generally get an even better approximation of the definite integral. We call this process Simpson’s Rule, named after Thomas Simpson (1710–1761), even though others had used this rule as much as 100 years prior.

## Simpson’s Rule

Given one point, we can create a constant function that goes through that point. Given two points, we can create a linear function that goes through those points. Given three points, we can create a quadratic function that goes through those three points (given that no two have the same $x$-value).

Consider three points $(x_{1},y_{1})$, $(x_{2},y_{2})$ and $(x_{3},y_{3})$ whose $x$-values are equally spaced and $x_{1}. Let $f$ be the quadratic function that goes through these three points. An exercise will ask you to show that

 $\int_{x_{1}}^{x_{3}}f(x)\operatorname{d}\!x=\frac{x_{3}-x_{1}}{6}\bigl{(}y_{1}% +4y_{2}+y_{3}\bigr{)}.$ (8.7.1)
margin: Figure 8.7.8: A graph of a function $f$ and a parabola that approximates it well on $[1,3]$. Λ

Consider Figure 8.7.8. A function $f$ goes through the 3 points shown and the parabola $g$ that also goes through those points is graphed with a dashed line. Using our equation from above, we know exactly that

 $\int_{1}^{3}g(x)\operatorname{d}\!x=\frac{3-1}{6}\bigl{(}3+4(1)+2\bigr{)}=3.$

Since $g$ is a good approximation for $f$ on $[1,3]$, we can state that

 $\int_{1}^{3}f(x)\operatorname{d}\!x\approx 3.$

Notice how the interval $[1,3]$ was split into two subintervals as we needed 3 points. Because of this, whenever we use Simpson’s Rule, we need to break the interval into an even number of subintervals.

In general, to approximate $\displaystyle\int_{a}^{b}f(x)\operatorname{d}\!x$ using Simpson’s Rule, subdivide $[a,b]$ into $n$ subintervals, where $n$ is even and each subinterval has width $\Delta x=(b-a)/n$. We approximate $f$ with $n/2$ parabolic curves, using Equation (8.7.1) to compute the area under these parabolas. Adding up these areas gives the formula:

 $\int_{a}^{b}f(x)\operatorname{d}\!x\approx\\ \frac{\Delta x}{3}\left[f(x_{0})+4f(x_{1})+2f(x_{2})+4f(x_{3})+\dotsb+2f(x_{n-% 2})+4f(x_{n-1})+f(x_{n})\right].$

Note how the coefficients of the terms in the summation have the pattern 1, 4, 2, 4, 2, 4, …, 2, 4, 1.

Let’s demonstrate Simpson’s Rule with a concrete example.

margin: $x_{i}$ $e^{-x_{i}^{2}}$ 0 1 0.25 0.939 0.5 0.779 0.75 0.570 1 0.368 (a) (b) Figure 8.7.9: A table of values to approximate $\int_{0}^{1}e^{-x^{2}}\operatorname{d}\!x$ in Example 8.7.5, along with a graph of the function. Λ
###### Example 8.7.5 Using Simpson’s Rule

Approximate $\displaystyle\int_{0}^{1}e^{-x^{2}}\operatorname{d}\!x$ using Simpson’s Rule and 4 equally spaced subintervals.

SolutionWe begin by making a table of values as we have in the past, as shown in Figure 8.7.9(a). Simpson’s Rule states that

 $\int_{0}^{1}e^{-x^{2}}\operatorname{d}\!x\approx\frac{0.25}{3}\Bigl{[}1+4(0.93% 9)+2(0.779)+4(0.570)+0.368\Bigr{]}=0.7468\overline{3}.$

Recall in Example 8.7.1 we stated that the correct answer, accurate to 4 places after the decimal, was 0.7468. Our approximation with Simpson’s Rule, with 4 subintervals, is better than our approximation with the Trapezoidal Rule using 5.

Figure 8.7.9(b) shows $f(x)=e^{-x^{2}}$ along with its approximating parabolas, demonstrating how good our approximation is. The approximating curves are nearly indistinguishable from the actual function.

margin: $x_{i}$ $\sin(x_{i}^{3})$ $-0.785$ $-0.466$ $-0.550$ $-0.165$ $-0.314$ $-0.031$ $-0.0785$ $\phantom{-}0$ $\phantom{-}0.157$ $\phantom{-}0.004$ $\phantom{-}0.393$ $\phantom{-}0.061$ $\phantom{-}0.628$ $\phantom{-}0.246$ $\phantom{-}0.864$ $\phantom{-}0.601$ $\phantom{-}1.10$ $\phantom{-}0.971$ $\phantom{-}1.34$ $\phantom{-}0.690$ $\phantom{-}1.57$ $-0.670$ (a) (b) Figure 8.7.10: A table of values to approximate $\int_{-\frac{\pi}{4}}^{\frac{\pi}{2}}\sin(x^{3})\operatorname{d}\!x$ in Example 8.7.6, along with a graph of the function. Λ
###### Example 8.7.6 Using Simpson’s Rule

Approximate $\displaystyle\int_{-\frac{\pi}{4}}^{\frac{\pi}{2}}\sin(x^{3})\operatorname{d}\!x$ using Simpson’s Rule and 10 equally spaced intervals.

SolutionFigure 8.7.10(a) shows the table of values that we used in the past for this problem, shown here again for convenience. Again, $\Delta x=(\pi/2+\pi/4)/10\approx 0.236$.

Simpson’s Rule states that

 $\displaystyle\int_{-\frac{\pi}{4}}^{\frac{\pi}{2}}\sin(x^{3})\operatorname{d}\!x$ $\displaystyle\approx\frac{0.236}{3}\Bigl{[}(-0.466)+4(-0.165)+2(-0.031)+\dotsb$ $\displaystyle\qquad\qquad\qquad\dotsb+2(0.971)+4(0.69)+(-0.67)\Bigr{]}$ $\displaystyle=0.4701$

Recall that the actual value, accurate to 3 decimal places, is 0.460. Our approximation is within $0.01$ of the correct value. The graph in Figure 8.7.10(b) shows how closely the parabolas match the shape of the graph.

## Summary and Error Analysis

We summarize the key concepts of this section thus far in the following Key Idea.

###### Key Idea 8.7.1 Numerical Integration

Let $f$ be a continuous function on $[a,b]$, let $n$ be a positive integer, and let $\displaystyle\Delta x=\frac{b-a}{n}$. Set $x_{0}=a$, $x_{1}=a+\Delta x$, …, $x_{i}=a+i\Delta x$, $x_{n}=b$. Then $\displaystyle\int_{a}^{b}f(x)\operatorname{d}\!x$ can be approximated by:
Left Hand Rule: $\Delta x\Bigl{[}f(x_{0})+f(x_{1})+\dotsb+f(x_{n-1})\Bigr{]}$. Right Hand Rule: $\Delta x\Bigl{[}f(x_{1})+f(x_{2})+\dotsb+f(x_{n})\Bigr{]}$. Midpoint Rule: $\Delta x\Bigl{[}f\bigl{(}\frac{x_{0}+x_{1}}{2}\bigr{)}+f\bigl{(}\frac{x_{1}+x_% {2}}{2}\bigr{)}+\dotsb+f\bigl{(}\frac{x_{n-1}+x_{n}}{2}\bigr{)}\Bigr{]}$. Trapezoidal Rule: $\frac{\Delta x}{2}\Bigl{[}f(x_{0})+2f(x_{1})+2f(x_{2})+\dotsb+2f(x_{n-1})+f(x_% {n})\Bigr{]}$. Simpson’s Rule: $\frac{\Delta x}{3}\Bigl{[}f(x_{0})+4f(x_{1})+2f(x_{2})+\dotsb+4f(x_{n-1})+f(x_% {n})\Bigr{]}$ ($n$ even).

In our examples, we approximated the value of a definite integral using a given method then compared it to the “right” answer. This should have raised several questions in the reader’s mind, such as:

1. (a)

How was the “right” answer computed?

2. (b)

If the right answer can be found, what is the point of approximating?

3. (c)

If there is value to approximating, how are we supposed to know if the approximation is any good?

These are good questions, and their answers are educational. In the examples, the right answer was never computed. Rather, an approximation accurate to a certain number of places after the decimal was given. In Example 8.7.1, we do not know the exact answer, but we know it starts with 0.7468. These more accurate approximations were computed using numerical integration but with more precision (i.e., more subintervals and the help of a computer).

Since the exact answer cannot be found, approximation still has its place. How are we to tell if the approximation is any good?

“Trial and error” provides one way. Using technology, make an approximation with, say, 10, 100, and 200 subintervals. This likely will not take much time at all, and a trend should emerge. If a trend does not emerge, try using yet more subintervals. Keep in mind that trial and error is never foolproof; you might stumble upon a problem in which a trend will not emerge.

A second method is to use Error Analysis. While the details are beyond the scope of this text, there are some formulas that give bounds for how good your approximation will be. For instance, the formula might state that the approximation is within 0.1 of the correct answer. If the approximation is 1.58, then one knows that the correct answer is between 1.48 and 1.68. By using lots of subintervals, one can get an approximation as accurate as one likes. Theorem 8.7.1 states what these bounds are.

###### Theorem 8.7.1 Error Bounds in Numerical Integration

Suppose that $K_{m}$ is an upper bound on $\left\lvert f^{(m)}(x)\right\rvert$ on $[a,b]$. Then a bound for the error of the numerical method of integration is given by:

 Method Error Bound Left/Right Hand Rule $\dfrac{K_{1}(b-a)^{2}}{2n}$ Midpoint Rule $\dfrac{K_{2}(b-a)^{3}}{24n^{2}}$ Trapezoidal Rule $\dfrac{K_{2}(b-a)^{3}}{12n^{2}}$ Simpson’s Rule $\dfrac{K_{4}(b-a)^{5}}{180n^{4}}$

1. (a)

The larger the interval, the larger the error. This should make sense intuitively.

2. (b)

The error shrinks as more subintervals are used (i.e., as $n$ gets larger).

3. (c)

When $n$ doubles, the Left and Right Hand Rules double in accuracy, the Midpoint and Trapezoidal Rules quadruple in accuracy, and Simpson’s Rule is 16 times more accurate.

4. (d)

The error in Simpson’s Rule has a term relating to the 4${}^{\text{th}}$ derivative of $f$. Consider a cubic polynomial: its $4^{\text{th}}$ derivative is 0. Therefore, the error in approximating the definite integral of a cubic polynomial with Simpson’s Rule is 0 — Simpson’s Rule computes the exact answer!

We revisit Examples 8.7.3 and 8.7.5 and compute the error bounds using Theorem 8.7.1 in the following example.

###### Example 8.7.7 Computing error bounds

Find the error bounds when approximating $\displaystyle\int_{0}^{1}e^{-x^{2}}\operatorname{d}\!x$ using the Trapezoidal Rule and 5 subintervals, and using Simpson’s Rule with 4 subintervals.

SolutionTrapezoidal Rule with $n=5$:

We start by computing the $2^{\text{nd}}$ derivative of $f(x)=e^{-x^{2}}$: margin: Figure 8.7.11: Graphing $f\,^{\prime\prime}(x)$ in Example 8.7.7 to help establish error bounds. Λ

 $f\,^{\prime\prime}(x)=e^{-x^{2}}(4x^{2}-2).$

Figure 8.7.11 shows a graph of $f\,^{\prime\prime}(x)$ on $[0,1]$. It is clear that the largest value of $f\,^{\prime\prime}$, in absolute value, is 2. Thus we let $M=2$ and apply the error formula from Theorem 8.7.1.

 $E_{T}=\frac{(1-0)^{3}}{12\cdot 5^{2}}\cdot 2=0.00\overline{6}.$

Our error estimation formula states that our approximation of 0.7445 found in Example 8.7.3 is within 0.0067 of the correct answer, hence we know that

 $0.7445-0.0067=.7378\leq\int_{0}^{1}e^{-x^{2}}\operatorname{d}\!x\leq 0.7512=0.% 7445+0.0067.$

We had earlier computed the exact answer, correct to 4 decimal places, to be 0.7468, affirming the validity of Theorem 8.7.1.

Simpson’s Rule with $n=4$:

We start by computing the $4^{\text{th}}$ derivative of $f(x)=e^{-x^{2}}$: margin: Figure 8.7.12: Graphing $f\,^{(4)}(x)$ in Example 8.7.7 to help establish error bounds. Λ

 $f\,^{(4)}(x)=e^{-x^{2}}(16x^{4}-48x^{2}+12).$

Figure 8.7.12 shows a graph of $f\,^{(4)}(x)$ on $[0,1]$. It is clear that the largest value of $f\,^{(4)}$, in absolute value, is 12. Thus we let $M=12$ and apply the error formula from Theorem 8.7.1.

 $E_{s}=\frac{(1-0)^{5}}{180\cdot 4^{4}}\cdot 12=0.00026.$

Our error estimation formula states that our approximation of $0.7468\overline{3}$ found in Example 8.7.5 is within 0.00026 of the correct answer, hence we know that

 $0.74683-0.00026=.74657\leq\int_{0}^{1}e^{-x^{2}}\operatorname{d}\!x\leq 0.7470% 9=0.74683+0.00026.$

Once again we affirm the validity of Theorem 8.7.1.

We have seen that, for $\displaystyle\int_{0}^{1}e^{-x^{2}}\operatorname{d}\!x$, Simpson’s Rule with 4 subintervals is far more accurate than the Trapezoidal Rule with 5 subintervals. We now find how many intervals we would need to match that accuracy.

###### Example 8.7.8 Finding a number subintervals

Find the number of subintervals necessary to estimate $\displaystyle\int_{0}^{1}e^{-x^{2}}\operatorname{d}\!x$ to within $0.00026$ using the Trapezoidal Rule.

SolutionWe can again use that $f\,^{\prime\prime}(x)$ is bounded by 2, so that

 $E_{T}=\frac{(1-0)^{3}}{12\cdot n^{2}}\cdot 2=\frac{1}{6n^{2}}.$

In order for this to be at most $0.00026$, we need to have

 $n\geq\frac{1}{\sqrt{6\cdot 0.00026}}\approx 25.3.$

Therefore, we will need at least 26 subintervals in order to have as much accuracy as Simpson’s Rule with 4 subintervals.

At the beginning of this section we mentioned two main situations where numerical integration was desirable. We have considered the case where an antiderivative of the integrand cannot be computed. We now investigate the situation where the integrand is not known. This is, in fact, the most widely used application of Numerical Integration methods. “Most of the time” we observe behavior but do not know “the” function that describes it. We instead collect data about the behavior and make approximations based off of this data. We demonstrate this in an example.

###### Example 8.7.9 Approximating distance traveled

One of the authors drove his daughter home from school while she recorded their speed every 30 seconds. The data is given in Figure 8.7.13. margin: Time Speed (min) (mph) 0 0 0.5 25 1 22 1.5 19 2 39 2.5 0 3 43 3.5 59 4 54 4.5 51 5 43 5.5 35 6 40 6.5 43 7 30 7.5 0 8 0 8.5 28 9 40 9.5 42 10 40 10.5 39 11 40 11.5 23 12 0 Figure 8.7.13: Speed data collected at 30 second intervals for Example 8.7.9. Λ Approximate the distance they traveled.

SolutionRecall that by integrating a speed function we get distance traveled. We have information about $v(t)$; we will use Simpson’s Rule to approximate $\displaystyle\int_{a}^{b}v(t)\operatorname{d}\!t.$

The most difficult aspect of this problem is converting the given data into the form we need it to be in. The speed is measured in miles per hour, whereas the time is measured in 30 second increments.

We need to compute $\Delta x=(b-a)/n$. Clearly, $n=24$. What are $a$ and $b$? Since we start at time $t=0$, we have that $a=0$. The final recorded time came after 24 periods of 30 seconds, which is 12 minutes or 1/5 of an hour. Thus we have

 $\Delta x=\frac{b-a}{n}=\frac{1/5-0}{24}=\frac{1}{120};\quad\frac{\Delta x}{3}=% \frac{1}{360}.$

Thus the distance traveled is approximately:

 $\displaystyle\int_{0}^{0.2}v(t)\operatorname{d}\!t$ $\displaystyle\approx\frac{1}{360}\Bigl{[}f(x_{1})+4f(x_{2})+2f(x_{3})+\dots+4f% (x_{n})+f(x_{n+1})\Bigr{]}$ $\displaystyle=\frac{1}{360}\Bigl{[}0+4\cdot 25+2\cdot 22+\dots+2\cdot 40+4% \cdot 23+0\Bigr{]}$ $\displaystyle\approx 6.2167\ \text{miles.}$

We approximate the author drove 6.2 miles. (Because we are sure the reader wants to know, the author’s odometer recorded the distance as about 6.05 miles.)

## Exercises 8.7

### Terms and Concepts

1. 1.

T/F: Simpson’s Rule is a method of approximating antiderivatives.

2. 2.

What are the two basic situations where approximating the value of a definite integral is necessary?

3. 3.

Why are the Left and Right Hand Rules rarely used?

4. 4.

Why is the Midpoint Rule rarely used?

### Problems

In Exercises 5–12., a definite integral is given.

1. (a)

Approximate the definite integral with the Trapezoidal Rule and $n=4$.

2. (b)

Approximate the definite integral with Simpson’s Rule and $n=4$.

3. (c)

Find the exact value of the integral.

1. 5.

$\displaystyle\int_{-1}^{1}x^{2}\operatorname{d}\!x$

2. 6.

$\displaystyle\int_{0}^{10}5x\operatorname{d}\!x$

3. 7.

$\displaystyle\int_{0}^{\pi}\sin x\operatorname{d}\!x$

4. 8.

$\displaystyle\int_{0}^{4}\sqrt{x}\operatorname{d}\!x$

5. 9.

$\displaystyle\int_{0}^{3}(x^{3}+2x^{2}-5x+7)\operatorname{d}\!x$

6. 10.

$\displaystyle\int_{0}^{1}x^{4}\operatorname{d}\!x$

7. 11.

$\displaystyle\int_{0}^{2\pi}\cos x\operatorname{d}\!x$

8. 12.

$\displaystyle\int_{-3}^{3}\sqrt{9-x^{2}}\operatorname{d}\!x$

In Exercises 13–20., approximate the definite integral with the Trapezoidal Rule and Simpson’s Rule, with $n=6$.

1. 13.

$\displaystyle\int_{0}^{1}\cos\big{(}x^{2}\big{)}\operatorname{d}\!x$

2. 14.

$\displaystyle\int_{-1}^{1}e^{x^{2}}\operatorname{d}\!x$

3. 15.

$\displaystyle\int_{0}^{5}\sqrt{x^{2}+1}\operatorname{d}\!x$

4. 16.

$\displaystyle\int_{0}^{\pi}x\sin x\operatorname{d}\!x$

5. 17.

$\displaystyle\int_{0}^{\pi/2}\sqrt{\cos x}\operatorname{d}\!x$

6. 18.

$\displaystyle\int_{1}^{4}\ln x\operatorname{d}\!x$

7. 19.

$\displaystyle\int_{-1}^{1}\frac{1}{\sin x+2}\operatorname{d}\!x$

8. 20.

$\displaystyle\int_{0}^{6}\frac{1}{\sin x+2}\operatorname{d}\!x$

In Exercises 21–24., find $n$ such that the error in approximating the given definite integral is less than $0.0001$ when using:

1. (a)

the Trapezoidal Rule

2. (b)

Simpson’s Rule

1. 21.

$\displaystyle\int_{0}^{\pi}\sin x\operatorname{d}\!x$

2. 22.

$\displaystyle\int_{1}^{4}\frac{1}{\sqrt{x}}\operatorname{d}\!x$

3. 23.

$\displaystyle\int_{0}^{\pi}\cos\big{(}x^{2}\big{)}\operatorname{d}\!x$

4. 24.

$\displaystyle\int_{0}^{5}x^{4}\operatorname{d}\!x$

In Exercises 25–26., a region is given. Find the area of the region using Simpson’s Rule:

1. (a)

where the measurements are in centimeters, taken in 1 cm increments, and

2. (b)

where the measurements are in hundreds of yards, taken in 100 yd increments.

1. 25.
2. 26.
1. 27.

Let $f$ be the quadratic function that goes through the points $(x_{1},y_{1})$, $(x_{1}+\Delta x,y_{2})$ and $(x_{1}+2\Delta x,y_{3})$. Show that $\displaystyle\int_{x_{1}}^{x_{1}+2\Delta x}f(x)\operatorname{d}\!x=\frac{% \Delta x}{3}(y_{1}+4y_{2}+y_{3})$.