Tutorials › Calculus II › Comparing Quadrature Cost and Accuracy

Quadrature and Error Bounds · Tutorial 364 of 998

Comparing Quadrature Cost and Accuracy

Learn how panel counts, evaluation costs, error orders, and derivative bounds shape the choice between composite trapezoidal and Simpson rules.

Intermediate 10 min read

What You'll Learn

  • Compare the panel and function-evaluation counts for the two composite rules
  • Interpret the trapezoidal and Simpson error bounds and their different rates of decrease
  • Choose panel counts to meet a prescribed error tolerance
  • Account for the even-panel requirement and positive minimum panel counts
  • Identify the derivative bounds needed to guarantee accuracy
  • Recognize when an error-bound comparison does not establish which estimate is actually closer

Why Compare Cost and Accuracy?

Numerical integration involves a practical choice: how many function values should be computed, and what accuracy can those evaluations guarantee? The composite trapezoidal and composite Simpson rules use the same number of function values when they use the same number of panels. Their error bounds, however, decrease at different rates as the panel count increases, and they require different derivative information.

These differences matter when function evaluations are expensive or when a guaranteed tolerance is required. A useful comparison must account for the interval, the derivative bounds, the panel restrictions, and the number of evaluations—not just the names of the methods.

Panel Counts, Evaluations, and Error Bounds

Let \(f\) be defined on \([a,b]\), where \(a<b\), and let \(L=b-a\). A composite rule divides the interval into panels and evaluates \(f\) at grid points. For the composite trapezoidal rule, \(n\) is any positive integer. For the composite Simpson rule, \(n\) must be a positive even integer. In both cases, \(n\) panels use \(n+1\) distinct grid-point values, including both endpoints.

Comparison: If \(f\) has a continuous second derivative on \([a,b]\) and \(|f''(x)|\le M_2\), the composite trapezoidal error satisfies \(\left|\int_a^b f(x)\,dx-T_n\right|\le M_2L^3/(12n^2)\). If \(f\) has a continuous fourth derivative and \(|f^{(4)}(x)|\le M_4\), the composite Simpson error satisfies \(\left|\int_a^b f(x)\,dx-S_n\right|\le M_4L^5/(180n^4)\), for positive even \(n\).

Here \(T_n\) and \(S_n\) denote the respective composite approximations. The derivative bounds are upper bounds on the entire interval, not values of the derivatives at a few sample points. If a bound is unknown, the corresponding formula alone does not give a numerical guarantee.

FeatureComposite trapezoidalComposite Simpson
Allowed panel countPositive integer \(n\)Positive even integer \(n\)
Function evaluations\(n+1\)\(n+1\)
Derivative information for the error boundA bound \(M_2\) for \(|f''|\)A bound \(M_4\) for \(|f^{(4)}|\)
Error-bound dependence on \(n\)Proportional to \(n^{-2}\)Proportional to \(n^{-4}\)

The powers \(n^{-2}\) and \(n^{-4}\) describe how the stated bounds scale when the interval and derivative bounds are held fixed. They do not say that the actual errors always have those exact sizes. In particular, an error bound can be much larger than the error that occurs for a particular function.

Choosing a Panel Count from a Tolerance

Suppose the requested absolute error tolerance is \(\varepsilon>0\). To guarantee the tolerance using the trapezoidal error bound, it is sufficient to require \(M_2L^3/(12n^2)\le\varepsilon\). Solving this inequality gives \(n\ge\sqrt{M_2L^3/(12\varepsilon)}\). Since \(n\) must be positive, a valid minimal choice is:

$$ n_T=\max\left\{1,\left\lceil\sqrt{\frac{M_2L^3}{12\varepsilon}}\right\rceil\right\}. $$

For Simpson’s rule, the bound requires \(n\ge\left(M_4L^5/(180\varepsilon)\right)^{1/4}\), as well as a positive even panel count. Thus choose the smallest positive even integer at least that threshold. If the threshold is zero, \(n=0\) is still not allowed: the smallest admissible count is \(2\).

$$ n_S=\text{the smallest positive even integer }n \text{ such that } n\ge\left(\frac{M_4L^5}{180\varepsilon}\right)^{1/4}. $$

These choices are sufficient based on the stated bounds. They are not necessarily the only ways to meet the tolerance: a particular function may have much smaller error than the bound predicts. When \(M_2=0\) or \(M_4=0\), use the minimum permitted positive panel count rather than interpreting a zero threshold as a valid zero-panel calculation.

Worked Example: Equal Panel Counts, Different Bounds

Worked Example: Equal Panel Counts, Different Bounds

Compare the error bounds for \(f(x)=e^x\) on \([0,1]\) using \(n=8\) panels. Here \(L=1\), and \(f''(x)=e^x\) and \(f^{(4)}(x)=e^x\). Both are bounded above by \(e\) on this interval, so take \(M_2=M_4=e\). Since \(8\) is even, both rules are permitted and each uses \(8+1=9\) function evaluations.

The trapezoidal bound is:

$$ \left|\int_0^1e^x\,dx-T_8\right| \le \frac{e(1)^3}{12(8)^2} =\frac{e}{768} \approx 0.0035394. $$

The Simpson bound is:

$$ \left|\int_0^1e^x\,dx-S_8\right| \le \frac{e(1)^5}{180(8)^4} =\frac{e}{737280} \approx 0.0000036869. $$

Both approximations use nine evaluations, but the Simpson bound is much smaller for these derivative bounds and this panel count. This comparison concerns the guaranteed upper bounds; it does not calculate the actual errors of the two approximations.

Check: The rule formulas use \(n=8\), and both require the values at the nine grid points from \(0\) through \(1\). The reported bounds follow by substituting \(L=1\), \(M_2=M_4=e\), and \(n=8\) into the respective error formulas.

Worked Example: Panel Counts for a Specified Tolerance

Worked Example: Panel Counts for a Specified Tolerance

Estimate \(\int_0^{\pi/2}\sin x\,dx\) with a guaranteed absolute error no greater than \(\varepsilon=0.001\). Since \(f''(x)=-\sin x\) and \(f^{(4)}(x)=\sin x\), both derivative magnitudes are at most \(1\) on this interval. Thus take \(M_2=M_4=1\) and \(L=\pi/2\).

For the trapezoidal rule, the threshold is:

$$ \sqrt{\frac{(\pi/2)^3}{12(0.001)}} = \sqrt{\frac{3.8757846\ldots}{0.012}} \approx \sqrt{322.9821} \approx 17.9717. $$

The smallest integer at least this large is \(n_T=18\), requiring \(19\) function evaluations. Its error bound is:

$$ \frac{(\pi/2)^3}{12(18)^2} = \frac{3.8757846\ldots}{3888} \approx 0.000996857 \le 0.001. $$

For Simpson’s rule, the threshold is:

$$ \left(\frac{(\pi/2)^5}{180(0.001)}\right)^{1/4} = \left(\frac{9.563116\ldots}{0.18}\right)^{1/4} \approx (53.1284)^{1/4} \approx 2.6998. $$

The smallest positive even integer at least this large is \(n_S=4\), requiring \(5\) function evaluations. Its error bound is:

$$ \frac{(\pi/2)^5}{180(4)^4} = \frac{9.563116\ldots}{46080} \approx 0.00020753 \le 0.001. $$

Check: The trapezoidal bound at \(18\) panels is below the tolerance, and \(18\) is the first integer at or above its threshold. The Simpson bound at \(4\) panels is below the tolerance, and \(4\) is the first admissible positive even count at or above its threshold. The evaluation counts are \(18+1=19\) and \(4+1=5\).

Why the Bounds Scale Differently

The panel-count dependence can be seen from the global error bounds. With \(L\), \(M_2\), and \(M_4\) fixed, the trapezoidal bound has \(n^2\) in its denominator, while the Simpson bound has \(n^4\). For example, doubling \(n\) reduces the trapezoidal bound by a factor of \(2^2=4\), and reduces the Simpson bound by a factor of \(2^4=16\), provided the same derivative bounds apply.

This scaling explains why Simpson’s rule can need fewer evaluations to meet a tolerance when the required fourth-derivative bound is available and useful. It does not, by itself, prove that Simpson is always more accurate. The constants \(M_2\) and \(M_4\) may differ greatly, the rules have different smoothness requirements, and each error bound can be conservative. A meaningful guarantee must use valid bounds for the specific function and interval.

Worked Example: A Zero Simpson Bound and the Minimum Panel Count

Worked Example: A Zero Simpson Bound and the Minimum Panel Count

Compare the rules for \(f(x)=x^3\) on \([0,1]\) with tolerance \(\varepsilon=0.01\). Here \(L=1\), \(f''(x)=6x\), so \(M_2=6\), and \(f^{(4)}(x)=0\), so \(M_4=0\).

The trapezoidal threshold is:

$$ \sqrt{\frac{6(1)^3}{12(0.01)}} =\sqrt{50} \approx 7.0711. $$

Thus \(n_T=8\), giving \(9\) evaluations. The trapezoidal approximation can be checked directly. With spacing \(h=1/8\), its grid values are \(f(k/8)=(k/8)^3\) for \(k=0,\ldots,8\), and:

$$ T_8 =\frac18\left[\frac{f(0)+f(1)}2+\sum_{k=1}^{7}f(k/8)\right] =\frac18\left[\frac12+\frac{1^3+2^3+\cdots+7^3}{512}\right]. $$

The sum of cubes is \(1+8+27+64+125+216+343=784\). Therefore:

$$ T_8=\frac18\left(\frac12+\frac{784}{512}\right) =\frac18\left(\frac{128}{256}+\frac{392}{256}\right) =\frac{65}{256} =0.25390625. $$

Since \(\int_0^1x^3\,dx=1/4=0.25\), the actual error is \(1/256=0.00390625\). The bound also verifies the requested tolerance: \(6/(12\cdot 8^2)=6/768=0.0078125\le0.01\).

For Simpson’s rule, the threshold is \((0)^{1/4}=0\), but the panel count must still be positive and even. Choose the minimum, \(n_S=2\), which uses \(3\) evaluations. The Simpson estimate is:

$$ S_2=\frac{1/2}{3}\left[f(0)+4f(1/2)+f(1)\right] =\frac16\left[0+4\left(\frac18\right)+1\right] =\frac16\left(\frac32\right) =\frac14. $$

Its error is zero, consistent with the Simpson bound \(M_4L^5/(180n^4)=0\). Check: The exact integral is \(1/4\), so substituting the computed Simpson estimate gives zero difference; the trapezoidal estimate differs by exactly \(1/256\), which is less than its guaranteed bound and the requested tolerance.

Derivative Information Is Part of the Cost

Function evaluations are the most visible computational cost, but they are not the whole story. To use the trapezoidal bound, one needs a valid upper bound for \(|f''|\) across the interval. To use the Simpson bound, one needs a valid upper bound for \(|f^{(4)}|\). Establishing either bound may require algebra, known inequalities, or other mathematical information about the function.

Consequently, a method can be inexpensive to evaluate but difficult to certify. If the fourth derivative is not continuous on the interval, or no valid bound for its magnitude is known, the stated Simpson error bound cannot be used as a guarantee. Likewise, the trapezoidal guarantee requires the stated second-derivative condition. A numerical estimate can still be computed from function values, but without the conditions and bounds its error is not certified by these formulas.

Practical takeaway: Compare methods using both evaluation counts and the information required to justify their error bounds. A smaller theoretical bound is useful only when its assumptions and derivative bound are valid.

Common Pitfall: Comparing Orders as if They Were Guarantees

A tempting but incorrect conclusion is: “Simpson has an \(n^{-4}\) error bound, so it is always more accurate than the trapezoidal rule.” The order describes how the bound scales with \(n\) under the stated smoothness and derivative-bound assumptions. It does not compare the actual errors for every function, nor does it ensure that the fourth-derivative information is available.

For instance, if \(f(x)=x^3\), the Simpson bound is zero because \(f^{(4)}(x)=0\), and Simpson is exact with two panels. But that conclusion follows from the actual derivative information and the Simpson error bound, not merely from the phrase “fourth order.” For another function, a loose or unavailable fourth-derivative bound may make the Simpson guarantee less useful in practice.

How to Make a Fair Comparison

1
Fix the interval and tolerance.
Record \(L=b-a\) and the requested absolute error \(\varepsilon\).
2
Check the hypotheses and derivative bounds.
Find valid \(M_2\) and, if available, \(M_4\) on the whole interval.
3
Find admissible panel counts.
Use the tolerance thresholds, remembering that trapezoidal panels are positive integers and Simpson panels are positive even integers.
4
Compare evaluations and guarantees.
For each chosen count \(n\), record \(n+1\) evaluations and verify that the corresponding error bound is at most \(\varepsilon\).

Summary

For the same panel count, both composite rules use \(n+1\) grid-point evaluations. The trapezoidal error bound requires a second-derivative bound and decreases proportionally to \(n^{-2}\); the Simpson bound requires a fourth-derivative bound and decreases proportionally to \(n^{-4}\). To choose a count for a guaranteed tolerance, solve the relevant bound inequality and then respect the rule’s admissible panel counts. In particular, a zero threshold never permits zero panels.

Check Your Understanding

Use the error-bound conditions and evaluation counts to answer these questions.

  1. How many function evaluations are required by a composite rule with \(n\) panels?
  2. What derivative bound is needed to apply the stated composite trapezoidal error bound, and what bound is needed for Simpson’s rule?
  3. Why must the Simpson panel count be rounded up to a positive even integer rather than merely to an integer?
  4. If the Simpson threshold is zero, what is the smallest admissible panel count?
  5. Why does a fourth-order error bound not by itself prove that Simpson’s rule is always more accurate than the trapezoidal rule?