Comparing Numerical Methods
Textbook Reference
| Primary source | OpenStax Calculus Volume 2, Section 1.5: “Numerical Integration” |
| Direct link | https://openstax.org/books/calculus-volume-2/pages/1-5-numerical-integration |
| Textbook used in class | Stewart, Calculus, Section 7.7: “Approximate Integration” |
Opening Scenario
Three numerical methods are now in hand: the Midpoint Rule, the Trapezoidal Rule, and Simpson’s Rule. They differ in accuracy (how fast the error shrinks as $n$ grows), in computational effort (how many function evaluations are required), and in their over/underestimate behavior. Choosing well among them for a given problem requires understanding these trade-offs.
Quick Reference
Summary table:
| Method | Coefficients | Error bound | Error rate |
|---|---|---|---|
| Left/Right endpoint | $1, 1, \ldots, 1$ (all) | $\frac{K_1(b-a)^2}{2n}$ | $O(1/n)$ |
| Midpoint Rule $M_n$ | $1, 1, \ldots, 1$ (midpoints) | $\frac{K_2(b-a)^3}{24n^2}$ | $O(1/n^2)$ |
| Trapezoidal Rule $T_n$ | $1, 2, 2, \ldots, 2, 1$ | $\frac{K_2(b-a)^3}{12n^2}$ | $O(1/n^2)$ |
| Simpson’s Rule $S_n$ | $1, 4, 2, 4, \ldots, 4, 1$ | $\frac{K_4(b-a)^5}{180n^4}$ | $O(1/n^4)$ |
where $K_1 = \max|f'|$, $K_2 = \max|f''|$, $K_4 = \max|f^{(4)}|$ on $[a,b]$.
Function evaluations per approximation:
- $L_n$ or $R_n$: $n$ evaluations.
- $M_n$: $n$ evaluations (midpoints, not the partition points).
- $T_n$: $n+1$ evaluations.
- $S_n$ with $n$ even: $n+1$ evaluations.
Key Concepts
1. Error Rates Interpreted
$O(1/n^2)$ means doubling $n$ reduces the error by a factor of $4$. $O(1/n^4)$ means doubling $n$ reduces the error by a factor of $16$. For modest accuracy requirements, $T_n$ or $M_n$ with $n = 100$ may suffice. For high accuracy, Simpson’s Rule with moderate $n$ outperforms all endpoint rules at the same cost.
2. Midpoint vs. Trapezoidal
Both have $O(1/n^2)$ error, but the error constants differ by a factor of 2:
- $|E_M| \leq \dfrac{K(b-a)^3}{24n^2}$
- $|E_T| \leq \dfrac{K(b-a)^3}{12n^2}$
The Midpoint Rule is therefore about twice as accurate as the Trapezoidal Rule for the same $n$. Moreover, for a concave-up function, $M_n$ underestimates and $T_n$ overestimates, so the true integral is trapped between them: $M_n < \int < T_n$. For concave-down, the inequalities reverse.
3. Simpson’s Rule as a Weighted Combination
$S_{2n} = \dfrac{2M_n + T_n}{3}$. This weighted average of the two $O(1/n^2)$ methods achieves $O(1/n^4)$ because the $O(1/n^2)$ terms in the error expansions for $M_n$ and $T_n$ cancel when combined with this specific weighting.
4. When to Use Which Method
- Endpoint rules: Only when high accuracy is not needed and computation must be minimal.
- Midpoint Rule: Good default for moderate accuracy; requires slightly fewer evaluations than $T_n$ for the same $n$ and is more accurate.
- Trapezoidal Rule: Useful when function values at the endpoints are already known (e.g., tabular data with measured boundary values).
- Simpson’s Rule: Best when the function is smooth (large derivatives would increase the $K_4$ constant), accuracy is important, and $n$ can be even.
“Simpson’s Rule is always better, so just always use it.” Simpson’s Rule requires $f^{(4)}$ to be bounded. For functions with large fourth derivatives, or for tabular data where derivatives are not available, $T_n$ or $M_n$ may be more appropriate. Also, if the function has corners or discontinuities, all polynomial-based rules have reduced convergence rates, and specialized methods may be needed.
Worked Example
For $\displaystyle\int_0^1 e^{-x^2}\,dx$, which method gives error $< 0.01$ with fewest function evaluations?
$f(x) = e^{-x^2}$. Compute some derivatives on $[0,1]$:
$f''(x) = (4x^2-2)e^{-x^2}$. Maximum of $|f''|$ on $[0,1]$: at $x=0$, $f''(0) = -2$; check endpoints. $\max|f''| \leq 2$.
$f^{(4)}(x)$ is more complex; its max on $[0,1]$ is approximately $12$.
Using $T_n$: $|E_T| \leq \dfrac{2(1)^3}{12n^2} = \dfrac{1}{6n^2} < 0.01$ requires $n^2 > 16.67$, so $n \geq 5$. Uses 6 evaluations.
Using $M_n$: $|E_M| \leq \dfrac{2(1)^3}{24n^2} = \dfrac{1}{12n^2} < 0.01$ requires $n^2 > 8.33$, so $n \geq 3$. Uses 3 evaluations.
Using $S_n$: $|E_S| \leq \dfrac{12(1)^5}{180n^4} = \dfrac{1}{15n^4} < 0.01$ requires $n^4 > 6.67$, so $n \geq 2$ (even). Uses 3 evaluations.
For 3 function evaluations, both $M_3$ and $S_2$ achieve the target. $S_2$ achieves $O(1/n^4)$ accuracy at the same cost, making it preferable for higher precision requirements.
Common Errors Summary
| Error | Example | Correction |
|---|---|---|
| Comparing $M_n$ and $T_n$ at different $n$ values | Claiming $T_{10}$ is more accurate than $M_{10}$ | For the same $n$, $M_n$ is about twice as accurate; compare at the same $n$ |
| Using the wrong derivative for the error bound | Using $|f''|$ in the Simpson’s Rule error formula | Simpson’s Rule uses $\max|f^{(4)}|$, not $\max|f''|$ |
| Claiming $T_n$ always overestimates | Applying over-estimate conclusion to a non-monotone function | Over/underestimate depends on concavity, not monotonicity; if concavity changes, neither rule has a guaranteed direction |
Leveled Practice
Level 1 -- Comparison
Problem 1. For $f(x) = x^3$ on $[0, 1]$, compute $M_2$, $T_2$, and $S_2$. Then compute $\int_0^1 x^3\,dx = \frac{1}{4}$ exactly. Which method is most accurate?
Show answer
$\Delta x = 0.5$.
$M_2$: midpoints $0.25$, $0.75$. $M_2 = 0.5[0.25^3 + 0.75^3] = 0.5[0.015625 + 0.421875] = 0.5(0.4375) = 0.21875$.
$T_2$: $T_2 = \frac{0.5}{2}[f(0)+2f(0.5)+f(1)] = 0.25[0 + 2(0.125) + 1] = 0.25(1.25) = 0.3125$.
$S_2$: $S_2 = \frac{0.5}{3}[f(0)+4f(0.5)+f(1)] = \frac{0.5}{3}[0 + 0.5 + 1] = \frac{0.5}{3}(1.5) = 0.25$.
Exact: $0.25$. Simpson’s Rule gives the exact answer (as expected: $f(x) = x^3$ is a cubic polynomial).
Mastery Checklist
Mental Model
Think of numerical integration methods as polynomial approximations of increasing degree:
- Rectangles: fit a degree-0 polynomial (constant) to the function on each subinterval. Error $O(1/n)$.
- Trapezoids: fit a degree-1 polynomial (line) to the two endpoints. Error $O(1/n^2)$.
- Parabolas (Simpson): fit a degree-2 polynomial to three points. Error $O(1/n^4)$.
Each degree upgrade multiplies accuracy by two powers of $n$. This pattern continues to higher-order methods in numerical analysis.
Connections
Looking back
- Trapezoidal and Midpoint Rules (Sections 4.2, 7.7): The two $O(1/n^2)$ methods being compared.
- Simpson’s Rule (Section 7.7): The $O(1/n^4)$ method that combines them.
Looking ahead
- Improper integrals (Section 7.8): Numerical methods are also used when the integrand has singularities or infinite limits, though extra care is required.
Back to Techniques of Integration | Next: Improper Integrals -- Infinite Limits