Calculus I 04.06 Numerical Integration
Previous | Calculus I 04.05 Integration by Substitution |
Next | Calculus I 05 Logarithmic, Exponential, and_Other Transcendental Functions |
Contents
4.6 Numerical Integration[1]
- Approximate a definite integral using the Trapezoidal Rule.
- Approximate a definite integral using Simpson’s Rule.
- Analyze the approximate errors in the Trapezoidal Rule and Simpson’s Rule.
The Trapezoidal Rule[2]
|
Some elementary functions simply do not have antiderivatives that are elementary functions. For example, the functions below lack any elementary function that is its antiderivative.
When evaluating a definite integral whose antiderivative cannot be found, or, cannot be easily applied even when the Fundamental Theorem of Calculus is still true, it is easier to resort to an approximation technique. Two techniques are The Trapezoidal Rule and The Simpson’s Rule, described here. One way to approximate a definite integral is to use \(n\) trapezoids, as shown in Figure 4.6.1. Let \(f\) be continuous and positive on the interval \([a,b]\). Therefore, the definite integral
represents the region's area bounded by the graph for \(f\) and the \(x\)-axis from \(x=a\) to \(x=b\). First, partition the interval \([a,b]\) into \(n\) subintervals, each \(\Delta x=(b-a)/n\), such that
Then form a trapezoid for each subinterval, as shown in Figure 4.6.2. The area for the \(i\)th trapezoid is |
|
This implies the formula for summing the areas for \(n\) trapezoids is
Letting \(\Delta x= (b-a)/n\), produces the limit as \(n \to \infty\) which yields The result is summarized in Theorem 4.6.1. |
Theorem 4.6.1 The Trapezoidal Rule
Let \(f\) be continuous on \([a,b]\). The Trapezoidal Rule for approximating \(\int_{a}^{b}f(x)dx\) is
- $$\int_{a}^{b}f(x)\:dx \approx \left ( \frac{b-a}{2n} \right )[f(x_0)+2f(x_1)+\cdot \cdot \cdot+2f(x_{n-1})+f(x_n)].$$
As \(n \to \infty \), the right-hand side approaches \(\int_{a}^{b}f(x)dx\). Observe the coefficients in the Trapezoidal Rule have the following pattern.
- 1 2 2 2 ... 2 2 1
Example 4.6.1 Approximation with the Trapezoidal Rule
|
Use the Trapezoidal Rule to approximate
Compare the results for \(n=4\) and \(n=8\), as shown in Figure 4.6.3.
Let \(n=8\) and \(\Delta x = \pi/8\), yields
This integral has an antiderivative found using techniques already discussed, the region's exact area is two. Thus illustrating that \(n \to \infty\) the approximation approaches the actual value. |
Compare the Trapezoidal Rule with the Midpoint Rule discussed in Section 4.2. The Trapezoidal Rule takes the average function values at the endpoints on the subintervals. But the Midpoint Rule takes the function values on the subinterval midpoints.
- $$\int_{a}^{b} f(x)\:dx \approx \sum_{i=1}^{n} f \left ( \frac{x_i+x_{i-1}}{2} \right ) \Delta x \:\:\:\:\:\:\:\:\:\:\:\:\:\: \color{red}{\text{Midpoint Rule}}$$
- $$\int_{a}^{b} f(x)\:dx \approx \sum_{i=1}^{n} \left ( \frac{f(x_i)+f(x_{i-1})}{2} \right ) \Delta x \:\:\:\:\: \color{red}{\text{Trapezoidal Rule}}$$
Two important points concerning the Trapezoidal Rule and the Midpoint Rule. First, the approximation is more accurate as \(n\) increases. For instance, in Example 4.6.1, when \(n =16\), the Trapezoidal Rule yields an approximation at 1.994. Much more accurate than the 1.974 approximation when \(n=8.\) Second, although the Fundamental Theorem of Calculus can evaluate the integral in Example 4.6.1, this theorem cannot be used to evaluate an integral as simple as \(\int_{0}^{\pi} \sin x^2\:dx\) because \(\sin x^2\) has no elementary antiderivative. Yet, the Trapezoidal Rule can be applied to estimate this integral.
Simpson's Rule[3]
One way to view the trapezoidal approximation for a definite integral is to say that on each subinterval, a first-degree polynomial is used to approximate \(f\). Simpson’s Rule, named after the English mathematician Thomas Simpson (1710–1761)[4], takes this procedure one step further and approximates \(f\) by second-degree polynomials.
Before presenting Simpson's Rule, consider Theorem 4.6.2 for evaluating integrals for polynomials with degree two, or fewer.
Theorem 4.6.2 Integral for \(p(x)=Ax^2+Bx+C\)
If \(p(x)=Ax^2+Bx+C\), then
- $$\int_{a}^{b} p(x)\:dx= \left ( \frac{b-a}{6} \right ) \left [ p(a)+4p \left ( \frac{a+b}{2} \right ) + p(b) \right ].$$
Proof
|
$$=\int_{a}^{b} (Ax^2+Bx+C)\:dx$$ |
$$=\left [ \frac{Ax^3}{3}+ \frac{Bx^2}{2}+Cx \right ]_{a}^{b}$$ | |
$$= \frac{A(b^3-a^3)}{3}+ \frac{B(b^2-a^2)}{2}+C(b-a)$$ | |
$$=\left ( \frac{b-a}{6} \right ) [2A(a^2+ab+b^2)+3B(b+a)+6C]$$ |
By expansion and collecting terms, the expression inside the brackets becomes $${\color{red}{\underbrace{\color{black}{(Aa^2+Ba+C)}}_{\color{red}{p(a)}}}}+{\color{red}{\underbrace{\color{black}{4\left [ A \left ( \frac{b+a}{2} \right )^2 + B\left ( \frac{b+a}{2} \right ) +C\right ]}}_{\color{red}{4p\frac{a+b}{2}}}}}+{\color{red}{\underbrace{\color{black}{(Ab^2+Bb+C)}}_{\color{red}{p(b)}}}}$$ and expressed as $$\int_{a}^{b} p(x)\:dx=\left ( \frac{b-a}{6} \right ) \left [ p(a)+4p \left ( \frac{a+b}{2} \right ) + p(b) \right ].$$
|
Applying Simpson’s Rule for approximating a definite integral by partitioning the interval \([a,b]\) into \(n\) subintervals, each \(\Delta x = (b-a)/2\) wide. The variable \(n\) must be even. The subintervals are grouped in pairs such that The double subintervals require that \(n\) be even. The approximation across each double subinterval \([x_{i-2},x_i]\) for \(f\) by a polynomial \(p\) with degree less than or equal to two. For example, on the subinterval \([x_0,x_2]\), choose the polynomial with the least degree passing through the points \((x_0,y_0),\:(x_1,y_1),\:\text{and}\:(x_2,y_2)\), as shown in Figure 4.6.4. By Theorem 4.6.2 and using \(p\) as an approximation for \(f\) on this subinterval produces
Repeating this procedure across the entire interval \([a,b]\) produces Theorem 4.6.3. |
Theorem 4.6.3 Simpson's Rule
Let \(f\) be continuous on \([a,b]\) and let \(n\) be an even integer. Simpson's Rule for approximating \(\int_{a}^{b}f(x)\:dx\) is
|
\(+4f(x_1)+2f(x_2)+4f(x_3)+\cdot \cdot \cdot\) |
\(+4f(x_{n-1})+f(x_n)].\) |
As \(n \to \infty\), the right-hand side approaches \(\int_{a}^{b}f(x)\:dx\).
Observe the coefficients in Simpson's Rule have the following pattern
- 1 4 2 4 2 4...4 2 4 1
In Example 4.6.1, the Trapezoidal Rule was used to estimate \(\int_{0}^{\pi} \sin x\:dx\). In Example 4.6.2, Simpson's Rule is applied to the same integral.
Example 4.6.2 Approximation with Simpson’s Rule
use Simpson's Rule to approximate
- $$\int_{0}^{\pi} \sin x\:dx.$$
Compare the results for \(n=4\) and \(n=8\).
Solution When \(n=4\), the result is
- $$\int_{0}^{\pi} \sin x\:dx \approx \frac{\pi}{12} \left ( \sin 0 + 4 \sin \frac{\pi}{4}+ 2 \sin \frac{\pi}{2} + 4\sin \frac{3\pi}{4} + \sin \pi \right ) \approx 2.005.$$
When \(n=8\), the result is
- $$\int_{0}^{\pi} \sin x\:dx \approx 2.0003.$$
Error Analysis
it is important to know how accurate an approximation technique is. Theorem 4.6.4 gives the formulas for estimating the error in Simpson’s Rule and the Trapezoidal Rule. In general the error \(E\) is the difference between \(\int_{a}^{b}f(x)\:dx\) and the approximation.
Theorem 4.6.4 Errors in the Trapezoidal Rule and Simpson’s Rule
If \(f\) has a continuous second derivative on \([a,b]\), then the error \(E\) in approximating \(\int_{a}^{b}f(x)\:dx\) by the Trapezoidal Rule is
|
Trapezoidal Rule |
if \(f\) has a continuous fourth derivative on \([a,b]\), then the error \(E\) is approximating \(\int_{a}^{b}f(x)\:dx\) by Simpson's Rule is
|
Simpson's Rule |
Theorem 4.6.4 states that the errors generated by the Trapezoidal Rule and Simpson’s Rule have upper bounds dependent on the extreme values for \({f}''(x)\) and \(f^{(4)}(x)\) in the interval \([a,b]\). Furthermore, these errors can be made arbitrarily small by increasing \(n\), provided that \({f}''\) and \(f^{(4)}\) are continuous and therefore bounded in \([a,b]\).
Example 4.6.3 The Approximate Error in the Trapezoidal Rule
|
Determine a value for \(n\) such that the Trapezoidal Rule will approximate the value for
with an error that is less than or equal to 0.01.
The maximum value for \(| {f}''(x)|\) on the interval \([0,1]\) is \(|{f}''(0)|=1\). By Theorem 4.6.4 the result is
To obtain an error \(E\) that is less than 0.01 choose \(n\) such that
Choose \(n=3\), because \(n\) must be greater or equal to 2.89, and apply the Trapezoidal Rule, as shown in Figure 4.6.5, to produce
By adding and subtracting the error from the estimate yields
|
Internal Links
Parent Article: Calculus I 04 Integration