<meta http-equiv="refresh" content="1; url=/nojavascript/"> Numerical Integration | CK-12 Foundation
Dismiss
Skip Navigation
You are reading an older version of this FlexBook® textbook: CK-12 Calculus Go to the latest version.

4.8: Numerical Integration

Created by: CK-12

Learning Objectives

  • Use the Trapezoidal Rule to solve problems
  • Estimate errors for the Trapezoidal Rule
  • Use Simpson’s Rule to solve problems
  • Estimate Errors for Simpson’s Rule

Introduction

Recall that we used different ways to approximate the value of integrals. These included Riemann Sums using left and right endpoints, as well as midpoints for finding the length of each rectangular tile. In this lesson we will learn two other methods for approximating integrals. The first of these, the Trapezoidal Rule, uses areas of trapezoidal tiles to approximate the integral. The second method, Simpson’s Rule, uses parabolas to make the approximation.

Trapezoidal Rule

Let’s recall how we would use the midpoint rule with n = 4 rectangles to approximate the area under the graph of f(x) = x^2 + 1 from x = 0 to x = 1.

If instead of using the midpoint value within each sub-interval to find the length of the corresponding rectangle, we could have instead formed trapezoids by joining the maximum and minimum values of the function within each sub-interval:

The area of a trapezoid is  A = \frac{h(b_1 + b_2)} {2} , where b_1 and b_2 are the lengths of the parallel sides and h is the height. In our trapezoids the height is \triangle x and b_1 and b_2 are the values of the function. Therefore in finding the areas of the trapezoids we actually average the left and right endpoints of each sub-interval. Therefore a typical trapezoid would have the area

 A = \frac{\triangle x} {2} \left (f(x_{i - 1}) + f(x_i) \right).

To approximate  \int_a^b f(x)dx with n of these trapezoids, we have

\int_{a}^{b} f(x)dx & \approx \frac{1}{2} \left [\sum_{i=1}^n f(x_{i-1})\triangle x+ \sum_{i=1}^n f(x_i)\triangle x \right ] \\& = \frac{\triangle x}{2} \left [f(x_0) + f(x_1) + f(x_1) + f(x_2) + f(x_2) + \ldots +f(x_{n-1}) + f(x_n) \right ] \\& = \frac{\triangle x}{2} \left [f(x_0) + 2f(x_1) + 2f(x_2) +  \ldots + 2f(x_{n-1}) + f(x_n) \right ],\triangle x = \frac{b-a}{n}.

Example 1:

Use the Trapezoidal Rule to approximate \int_{0}^{3} x^2 dx with n = 6.

Solution:

We find \triangle x = \frac{b-a}{n} = \frac{3-0}{6} = \frac{1}{2}.

\int_{0}^{3} x^2 dx & \approx \frac{1}{4} \begin{bmatrix} f(0)+2f(\frac{1}{2})+2f(1)+2f(\frac{3}{2})+2f(2) + 2f(\frac{5}{2})+f(3)\end{bmatrix} \\& = \frac{1}{4} \begin{bmatrix} 0+(2\cdot\frac{1}{4})+(2\cdot 1)+(2\cdot\frac{9}{4})+(2\cdot 4)+(2\cdot\frac{25}{4})+9 \end{bmatrix} \\& = \frac{1}{4} \begin{bmatrix} \frac{73}{2} \end{bmatrix} = \frac{73}{8} = 9.125.

Of course, this estimate is not nearly as accurate as we would like. For functions such as f(x) = x^2, we can easily find an antiderivative with which we can apply the Fundamental Theorem that \int_{0}^{3} x^2dx = \frac{x^3}{3}\Bigg]_0^3 = 9. But it is not always easy to find an antiderivative. Indeed, for many integrals it is impossible to find an antiderivative. Another issue concerns the questions about the accuracy of the approximation. In particular, how large should we take n so that the Trapezoidal Estimate for \int_{0}^{3} x^2 dx is accurate to within a given value, say 0.001? As with our Linear Approximations in the Lesson on Approximation Errors, we can state a method that ensures our approximation to be within a specified value.

Error Estimates for Simpson's Rule

We would like to have confidence in the approximations we make. Hence we can choose n to ensure that the errors are within acceptable boundaries. The following method illustrates how we can choose a sufficiently large n.

Suppose |f''(x)| \le k for a \le x \le b. Then the error estimate is given by

|Error_{Trapezoidal}| \le \frac{k(b-a)^3}{12n^2}.

Example 2:

Find n so that the Trapezoidal Estimate for \int_{0}^{3}x^2dx is accurate to 0.001.

Solution:

We need to find n such that |Error_{Trapezoidal}| \le 0.001. We start by noting that |f''(x)| = 2 for 0 \le x \le 3. Hence we can take k = 2 to find our error bound.

|Error_{Trapezoidal}| \le \frac{2(3-0)^3}{12n^2} = \frac{54}{12n^2}.

We need to solve the following inequality for n:

 \frac{54}{12n^2} & < 0.001, \\n^2 & > \frac{54}{12(0.001)}, \\n & > \sqrt{\frac{54}{12(0.001)}} \approx 67.08.

Hence we must take n = 68 to achieve the desired accuracy.

From the last example, we see one of the weaknesses of the Trapezoidal Rule—it is not very accurate for functions where straight line segments (and trapezoid tiles) do not lead to a good estimate of area. It is reasonable to think that other methods of approximating curves might be more applicable for some functions. Simpson’s Rule is a method that uses parabolas to approximate the curve.

Simpson’s Rule:

As was true with the Trapezoidal Rule, we divide the interval [a,b] into n sub-intervals of length \triangle x = \frac{b-a}{n}. We then construct parabolas through each group of three consecutive points on the graph. The graph below shows this process for the first three such parabolas for the case of n = 6 sub-intervals. You can see that every interval except the first and last contains two estimates, one too high and one too low, so the resulting estimate will be more accurate.

Using parabolas in this way produces the following estimate of the area from Simpson’s Rule:

\int_{a}^{b} f(x)dx \approx \frac {\triangle x}{3} \left [f(x_0)+4f(x_1)+2f(x_2)+4f(x_3)+2f(x_4)\ldots+2f(x_{n-2})+4f(x_{n-1})+f(x_n) \right ].

We note that it has a similar appearance to the Trapezoidal Rule. However, there is one distinction we need to note. The process of using three consecutive x_i to approximate parabolas will require that we assume that n must always be an even number.

Error Estimates for the Trapezoidal Rule

As with the Trapezoidal Rule, we have a formula that suggests how we can choose n to ensure that the errors are within acceptable boundaries. The following method illustrates how we can choose a sufficiently large n.

Suppose |f^4(x)| \le k for a \le x \le b. Then the error estimate is given by

|Error_{simpson}| \le \frac{k(b-a)^5}{180n^4}.

Example 3:

a. Use Simpson’s Rule to approximate \int_{1}^{4}\frac{1}{x}dx with n = 6.

Solution:

We find \triangle x = \frac{b-a}{n} = \frac{4-1}{6} = \frac{1}{2}.

\int_{1}^{4} \frac{1}{x}dx & \approx \frac{1}{6} \begin{bmatrix}f(1)+4f(\frac{3}{2})+2f(2)+4f(\frac{5}{2}) +2f(3)+4f(\frac{7}{2})+f(4)\end{bmatrix} \\& = \frac{1}{6} \begin{bmatrix} 1+(4\cdot\frac{2}{3})+(2\cdot\frac{1}{2})+(4\cdot\frac{2}{5})+(2\cdot\frac{1}{3})+(4\cdot\frac{2}{7})+\frac{1}{4}\end{bmatrix} \\& = \frac{1}{6} \begin{bmatrix} \frac{3517}{420}\end{bmatrix} = 1.3956.

This turns out to be a pretty good estimate, since we know that

\int_{1}^{4}\frac{1}{x}dx = \ln x \bigg ]_1^4 = \ln(4) - \ln(1) = 1.3863.

Therefore the error is less than 0.01.

b. Find n so that the Simpson Rule Estimate for \int_{1}^{4} \frac{1}{x}dx is accurate to 0.001.

Solution:

We need to find n such that |Error_{simpson}| \le 0.001. We start by noting that \left|f^4(x)\right| = \left|\frac{24}{x^5}\right| for 1 \le x \le 4. Hence we can take K = 24 to find our error bound:

|Error_{simpson}| \le \frac{24(4-1)^5}{180n^4} = \frac{5832}{180n^4}.

Hence we need to solve the following inequality for n:

 \frac{5832}{180n^4}<0.001.

We find that

 n^4 & > \frac{5832}{180(0.001)}, \\n & > 4 \sqrt {\frac {5832}{180(0.001)}} \approx 13.42.

Hence we must take n = 14 to achieve the desired accuracy.

Technology Note: Estimating a Definite Integral with a TI-83/84 Calculator

We will estimate the value of  \int_1^4 \frac{1} {x}dx .

  1. Graph the function  f(x) = \frac{1} {x} with the [WINDOW] setting shown below.
  2. The graph is shown in the second screen.
  3. Press 2nd [CALC] and choose option 7 (see menu below)
  4. When the fourth screen appears, press [1] [ENTER] then [4] [ENTER] to enter the lower and upper limits.
  5. The final screen gives the estimate, which is accurate to 7 decimal places.

Lesson Summary

  1. We used the Trapezoidal Rule to solve problems.
  2. We estimated errors for the Trapezoidal Rule.
  3. We used Simpson’s Rule to solve problems.
  4. We estimated Errors for Simpson’s Rule.

Multimedia Links

For video presentations of Simpson's Rule (21.0), see Simpson's Rule, Approximate Integration (7:21)

and Math Video Tutorials by James Sousa, Simpson's Rule of Numerical Integration (8:48).

Review Questions

  1. Use the Trapezoidal Rule to approximate \int_{0}^{1}x^2 e^{-x} dx with n = 8.
  2. Use the Trapezoidal Rule to approximate \int_{1}^{4}{ \ln}\sqrt {x} dx with n = 6.
  3. Use the Trapezoidal Rule to approximate \int_{0}^{1}\sqrt {1+x^4} dx with n = 4.
  4. Use the Trapezoidal Rule to approximate \int_{1}^{3}\frac {1}{x} dx with n = 8.
  5. How large should you take n so that the Trapezoidal Estimate for \int_{1}^{3}\frac {1}{x} dx is accurate to within 0.001?
  6. Use Simpson’s Rule to approximate \int_{0}^{1}x^2 e^{-x} dx with n = 8.
  7. Use Simpson’s Rule to approximate \int_{1}^{4}\sqrt {x}\ {\ln}\ x dx with n = 6.
  8. Use Simpson’s Rule to approximate \int_{0}^{2}\frac {1}{\sqrt {x^4+1}} dx with n = 6.
  9. Use Simpson’s Rule to approximate \int_{0}^{1} \sqrt {1+x^4} dx with n = 4.
  10. How large should you take n so that the Simpson Estimate for \int_{0}^{2} {e} dx is accurate to within 0.00001?

Review Answers

  1. \int_{0}^{1}x^2 e^{-x} dx \approx 0.16
  2. \int_{1}^{4}{ \ln}\sqrt {x} dx \approx 1.26
  3. \int_{0}^{1}\sqrt {1+x^4} dx \approx 1.10
  4. \int_{1}^{3}\frac {1}{x} dx \approx 1.10
  5. Take n = 37
  6. \int_{0}^{1}x^2 e^{-x} dx \approx 0.16
  7. \int_{1}^{4}\sqrt {x} { \ln}\ x dx \approx 4.28
  8. \int_{0}^{2}\frac {1}{\sqrt {x^4+1}} dx \approx 1.36
  9. \int_{0}^{1} \sqrt {1+x^4} dx \approx 1.09
  10. Take n = 1

Texas Instruments Resources

In the CK-12 Texas Instruments Calculus FlexBook, there are graphing calculator activities designed to supplement the objectives for some of the lessons in this chapter. See http://www.ck12.org/flexr/chapter/9729.

Image Attributions

Files can only be attached to the latest version of None

Reviews

Please wait...
Please wait...
Image Detail
Sizes: Medium | Original
 
CK.MAT.ENG.SE.1.Calculus.4.8

Original text