Numerical Integration
|
Return to Main Page
Index of On-Line Topics Exercises for This Topic Everything for Calculus Utility: Numerical Integration Utility TI-83: Graphing Calculator Programs Español |
The simplest numerical approximations to the integral are the left and right Riemann sums. More efficient approximations (below) are the trapezoidal and Simpson approximations.
Left and Right Riemann SumsIn Calculus Applied to the Real World, we defined the left Riemann sum as follows:
Left Riemann Sum | $= \sum_{n = 0}^{n-1} f(x_k)Δx$ |
$= f(x_0)Δx + f(x_1)Δx + . . . + f(x_{n-1})Δx$ | |
$= [f(x_0) + f(x_1) + . . . + f(x_{n-1})]Δx$ |
The left Riemann sum gives the area shown below.
Notice that the left side of each rectangle matches the height of the graph -- hence the name "left sum." The right Riemann sum is defined similarly:
Right Riemann Sum | $= \sum_{n = 1}^{n} f(x_k)Δx$ |
$= f(x_1)Δx + f(x_2)Δx + ... + f(x_n)Δx $ | |
$= [f(x_1) + f(x_2) + ... + f(x_n)]Δx$ |
The right Riemann sum gives the area shown below.
Example 1 Computing Left- and Right Riemann Sums
Solution
The left Riemann sum for the function is illustrated here:
To compute it, we use the following setup:
A trapezoid is a four-sided region with two opposite sides parallel. In the figure below, it is the two vertical sides that are parallel.
The area of a trapezoid is the average length of the parallel sides, times the distance between them.
Given a partition of $[a, b]$ as above, we can define the associated trapezoid sum to correspond to the area shown below.The areas of the individual trapezoids (from left to right) are as follows.
Leftmost trapezoid: | $\frac{1}{2} (f(x_0) + f(x_1))Δx$ | Average height $\times$ width |
Next trapezoid: | $\frac{1}{2} (f(x_1) + f(x_2))Δx$ | |
. . . | ||
Last trapezoid: | $\ \ \frac{1}{2} (f(x_{n-1}) + f(x_n))Δx$ | |
Adding these together, gives the trapezoid sum:
Trapezoid Sum | $= \frac{1}{2} (f(x_0) + f(x_1))Δx + \frac{1}{2} (f(x_1) + f(x_2))Δx + . . . + \frac{1}{2} (f(x_{nµ1}) + f(x_n))Δx$ |
Simplifying gives
Trapezoid Sum The trapezoid approximation of $\int_{a}^{b}\ f(x)\ dx$ associated with the partition $a = x_0 < x_1 < ... < x_n = b$ is given by
|
If you look carefully at the above formula, you will see that the trapezoid sum is just the average of the left- and right Riemann sums.
Example 2 Computing a Trapezoid Sum
Solution
In view of the comment immediately above, we have already computed it, in effect:
Trapezoid Sum | $=$ Average of Left- and Right Riemann Sums |
$=\frac{0.7265625 + 0.6015625}{2} = 0.6640625$ |
Q How about computing the trapezoid sum without first computing the left- and right Riemann sums?
A Here is an example.
Example 3 Computing a Trapezoid Sum
Solution
Since $n = 4,$ the width of the subintervals is $(b - a)/4 = (2 - 1)/4 = 0.25.$Now proceed as follows using the table below:
1. Enter the correct partition values $(x_0,$ $x_1, ... ).$Before we go on...
To automate the entire calculation, or to use much larger values of $n,$ try our Numerical Integration Utility.
Simpson's Rule If $n$ is even, and, as before, $x_k = a + kΔx = a + k (b - a)/n,$ then
|
Q Why?
Area under parabola $= \frac{b - a}{3n} [f(x_{k-1}) + 4f(x_k) + f(x_{k+1})].$ |
When we add the area under the parabola over the first two strips to the area under the parabola over the 3rd and 4th strips, and so on, we get Simpson's rule.
Example 4 Simpson's Rule
Solution
Since $n = 4,$ we have $(b - a)/n = 1/4,$ and Simpson's rule tells us that
$\int_{0}^{1}\ f(x)\ dx \approx \frac{b - a}{3n} [f(x_0) + 4f(x_1) + 2f(x_2) + 4f(x_3) + f(x_4)]$ |
$= \frac{1}{12} [0 + 4(0.0625) + 2(0.25) + 4(0.5625) + 1] = \frac{1}{3}.$ |
Before we go on...
This is the exact answer. What is going on? Remember that Simpson's rule is based on approximating the graph by quadratic functions. If the function is already quadratic, as it is here, the approximation is exact.
Example 5 Simpson's Rule
Solution
The following table summarizes the main part of the computation. (Figures are rounded to 6 decimal places.)
$x$ | $0$ | $1$ | $2$ | $3$ | $4$ | $5$ | $6$ |
$f(x) = e^{-x^2}$ | $1$ | $0.367879$ | $0.018316$ | $0.000123$ | $0$ | $0$ | $0$ |
![]() | $\times 4$![]() | $\times 2$![]() | $\times 4$![]() | $\times 2$![]() | $\times 4$![]() | ![]() | |
$1$ | $1.471518$ | $0.036631$ | $0.000494$ | $0$ | $0$ | $0$ |
The following formulas give bounds on the errors for the rules we have been using.
The Errors in the Trapezoid Rule and Simpson's Rule If $f"(x)$ is continuous in $[a,\ b],$ then the error in the trapezoid rule is no larger than
If $f^{(4)}(x)$ is continuous in $[a,\ b],$ then the error in Simpson's rule is no larger than
|
Example 6 Estimating the Error in the Trapezoid Sum
How accurate is the calculation in Example 3?
Solution
In that example we used 4 intervals in the trapezoid rule to estimate $\int_{1}^{2}\ e^{-x^2} dx.$ In order to estimate the error, we need to find the largest value of $\|f" (x)\|$ in the interval $[1,\ 2].$ for $f(x) = e^{-x^2}.$Calculating,
$x$ | $1$ | $1.225$ | $2$ |
$\color{blue}{f" (x)}$ | $0.74$ | $0.90$ | $0.26$ |
Example 7 Estimating the Error in the Simpson Sum
Solution
"Accurate to $5$ decimal places" means an error of less than $0.000 005.$ In this problem, we don't know the value of $n,$ but we do know an upper bound for the error.Our formula for the error in Simpson's rule says that
A quick calculation shows that the $4th$ derivative of $f$ is
As before, we have overestimated rather than underestimated the quantity e (never underestimate an error!). This gives
$\|Error\| ≤ \frac{(b - a)^5}{180n^4} \|f^{(4)}(M)|$ |
$< \frac{3^5}{180n^4}3 = \frac{81}{20n^4}.$ |
Return to Main Page
Index of On-Line Topics Exercises for This Topic Everything for Calculus Utility: Numerical Integration Utility TI-83: Graphing Calculator Programs |