From first principles
Estimate a missing integral from two mesh sizes
Suppose a quadrature approximation on a fixed interval has the asymptotic form \(Q_h=I+Ch^p+o(h^p)\), where \(p>0\) is known from the rule and smoothness assumptions. Evaluate the same rule after halving all panel widths. Its leading error is divided by \(2^p\), so eliminating \(C\) yields
The magnitude estimates the remaining fine-grid error. For composite Simpson quadrature \(p=4\) and the denominator is 15. An adaptive algorithm repeats this comparison on individual panels. Giving children absolute budgets that sum to their parent’s budget makes local bounds additive,
The first inequality is exact, while the estimated local errors require the leading-power model to hold. Two rules can agree accidentally on unresolved structure, which makes independent refinement or smoothness information valuable for difficult integrands.
Derivation and applications
Set a meaningful integration tolerance when contributions cancel
An adaptive integrator can refine its mesh until truncation error is small, yet the requested relative accuracy may be limited by uncertainty in the integrand. Consider an integrable real \(f\) on \([a,b]\) with pointwise error bounded by \(|\delta f(x)|\le\eta|f(x)|\). This can represent a numerical evaluation error or a relative tolerance on measured input values. The resulting data-induced error in the exact integral is bounded directly by
If arbitrary signs of perturbation are allowed, the bound is attained by taking \(\delta f=\eta|f|\). Let \(I_+\) and \(I_-\) be the respective positive magnitudes of the positive and negative contributions. For \(I\ne0\) the relative sensitivity to the data is therefore
It equals one for a one-sign integrand and can diverge as the net area tends to zero. If the algorithm has an independent absolute discretization error budget \(E_Q\), add the separate errors before deciding whether the requested tolerance is meaningful,
Splitting at known sign changes makes estimates of the separate contribution magnitudes easier to audit. It does not undo cancellation in the underlying quantity. Correlated data errors can yield a less severe budget when their correlation is independently known; a uniform multiplicative calibration error, for example, scales the net integral itself.
Worked example
Budget a nearly balanced energy flux
Heat-flow contributions over an interval are \(I_+=1001\,\mathrm J\), \(I_-=999\,\mathrm J\). The net is \(2\,\mathrm J\), and \(\kappa_I=1000\). With relative data uncertainty \(10^{-4}\), the data alone allow a \(0.20\,\mathrm J\) discrepancy, or ten percent of the net value. Reducing the quadrature budget from \(0.010\) to \(0.001\,\mathrm J\) cannot deliver one percent total accuracy.
Second application
Select an absolute budget from a reporting target
A second experiment has \(I_+=8.0\), \(I_-=3.0\) and \(\eta=0.002\). The data contribution is at most \(0.022\). Reporting net area 5.0 to one percent allows absolute error \(0.050\). A quadrature budget of \(0.028\) or smaller fits the remaining allowance. Two subinterval budgets of \(0.014\) each would satisfy the same total constraint.
Use two resolutions to estimate a missing integral
Suppose a composite rule on a smooth integrand has \(Q_h=I+Ch^p+O(h^{p+2})\). Halving the uniform spacing gives
Subtract the two approximations to eliminate \(I\). The fine-grid error satisfies
The sign of this estimate matters if correcting the numerical answer. Its magnitude supplies an error indicator. The relation assumes the same leading power operates on both grids and that the error exceeds the noise in the data.
For Simpson’s rule \(p=4\). On a parent interval compare one Simpson panel \(S\) with two half-panels whose sum is \(S_2\). The fine estimate of the local integral error is \(|S_2-S|/15\), and an extrapolated value is \(S_2+(S_2-S)/15\). The comparison needs only two new function evaluations because the endpoints and original midpoint are reused. If the indicator is too large, split the interval and apply the same test to each child separately.
Build a global tolerance from local decisions
Let the total absolute tolerance be \(\epsilon\). Begin with the whole interval assigned that budget. When a panel splits, a simple allocation gives half its budget to each child. By induction the sum of all final panel budgets equals the original tolerance. If each local actual error lies within its budget, the triangle inequality bounds the global error by \(\epsilon\). In practice the indicators estimate those actual errors, so this last statement is conditional. Around a discontinuity the fourth-order expansion can fail, and tiny intervals can run into evaluation noise or floating-point spacing.
For signed integrals with strong cancellation, relative error alone is hard to interpret. A large positive area and nearly equal negative area may give a tiny sum that changes sign under rounding. Use an absolute tolerance meaningful for the physical output, possibly combined with a relative term based on a stable scale. Reusing shared endpoint values helps both reproducibility and cost, especially when each evaluation invokes a constitutive model or a simulation.
Inspect one accepted panel and one failure
On \([0,1]\) use \(f(x)=x^4\). One Simpson panel gives \(S=0.20833333\), and two panels give \(S_2=0.20052083\). Their difference divided by 15 is \(-0.00052083\). The corrected result is 0.2, exactly the known integral up to the printed rounding. Here the fourth derivative is constant and there are no higher powers in the integrand, so cancellation removes the entire leading error. An estimated error of \(5.21\times10^{-4}\) would pass a local tolerance of \(10^{-3}\) while \(10^{-4}\) would trigger another split.
Now consider a narrow triangular pulse entirely between 0.10 and 0.11 of the interval, with height one. Its exact area is 0.005. The five points initially used by adaptive Simpson are \(0,0.25,0.5,0.75,1\). Every sampled ordinate is zero. The algorithm would accept zero with a zero indicator, even with a very small tolerance. This failure follows from lack of information, and it applies to any finite deterministic sample set when arbitrary narrow features are permitted. If event times or material interfaces are known, partition at them before sampling. If smoothness bounds are available, they supply an independent scale for an initial mesh. A small estimated local error should be interpreted together with those physical and mathematical assumptions.
Choose an independent comparison
A practical confirmation is to integrate the same signal using a different initial split and a different set of quadrature nodes. If a narrow pulse missed on one mesh is intersected on the other, their discrepancy reveals that the earlier indicator was misleading. Agreement between both estimates improves confidence but still cannot rule out an arbitrarily narrow feature absent from both sample sets.
When a physical bound \(|f'|\leq B\) is known, it supplies complementary information. Across an unsampled gap of width \(h\) whose endpoint values are both zero, a possible positive pulse is bounded by two straight ramps of slopes \(+B\) and \(-B\). Integrating the triangular envelope gives a maximum hidden area \(Bh^2/4\). A credible slope bound therefore turns a statement about unsampled behaviour into a quantitative reason to reduce the largest gap.
Build an independent certificate for an accepted panel
Adaptive extrapolation estimates error by comparing sampled values. A rigorous alternative is available when the model supplies a valid bound \(M\) on the fourth derivative throughout an interval. For a single Simpson panel of full width \(H\), the absolute error is bounded by \(M H^5/2880\). One derivation uses the cubic Hermite interpolant through both endpoint values and the midpoint value with its derivative at the midpoint. Its remainder is \(f^{(4)}(\xi)(x-a)(x-m)^2(x-b)/24\) for \(m=(a+b)/2\), assuming sufficient smoothness. The factor multiplying the derivative has one sign throughout the interval.
Integrating that polynomial factor in absolute value gives \(H^5/120\), and dividing by 24 gives the stated denominator 2880. Simpson quadrature integrates the cubic interpolant exactly and sees precisely the same three values as the original function. The midpoint derivative enters this argument as a mathematical device but never has to be measured. With independent derivative bounds on separate panels, summing their absolute bounds gives a global certificate without assuming that leading error terms cancel. Such bounds can be conservative, especially when worst allowed curvature occurs only over a tiny region.
A peak that agrees at every initial sample
On \([0,1]\) consider \(f(x)=x^2(1-x)^2\), with zero endpoints and midpoint value \(1/16\). Its single Simpson estimate is \(1/24\). The exact integral is \(1/3-1/2+1/5=1/30\), hence the overestimate is \(1/120\). The fourth derivative is exactly 24. Substituting \(M=24,H=1\) gives the same bound \(1/120\), attained in this case because the fourth derivative has constant sign and magnitude. Dividing into two equal Simpson panels lowers the total bound to \(2(1/2)^5/120=1/1920\).
A different candidate integrand makes the danger of relying on the sampled discrepancy explicit. Let \(g(x)=1-\cos(8\pi x)\). The original three samples and the two additional quarter-point samples are all zero. Both the coarse and refined Simpson estimates are therefore zero, so the usual difference indicator vanishes. Yet its exact integral on the unit interval is one. An independently known derivative bound \(M=(8\pi)^4\) gives a positive a priori certificate; the coarse computation cannot legitimately claim a small guaranteed error from those samples.
For equal panels the total fourth-derivative bound here is \(M/(2880 n^4)\) for \(n\) Simpson panels. To ensure an absolute error below 0.01 using only this information requires \(n>(M/28.8)^{1/4}\), about 10.85, so eleven panels suffice. The guarantee costs more evaluations than an indicator that happens to stop immediately, but it addresses a different question. Before using it for noisy measured data, check whether a fourth derivative is physically bounded at all and account for sampling error in addition to quadrature.
On the oscillatory example an offset sample at \(x=1/8\) gives value two, exposing the failure immediately. That single observation is powerful diagnostically, but its inclusion alone does not provide an accuracy bound for every other admissible integrand. The derivative certificate applies to the whole class with the stated derivative limit and therefore answers a stronger question.
Allocate a certified global Simpson budget
Suppose two smooth regions have lengths \(L_i\) and known bounds \(M_i\) on the fourth derivative. Give region \(i\) exactly \(n_i\) equal Simpson panels. Its contribution to the absolute error bound is \(M_iL_i^5/(2880n_i^4)\). For a fixed total panel count the best continuous allocation minimises the sum of these two expressions. Differentiating with a multiplier gives \(M_iL_i^5/n_i^5\) constant across regions, hence \(n_i\) proportional to \(L_i M_i^{1/5}\). The exponent is one fifth because each extra panel reduces the fourth-power global error at a rate proportional to the inverse fifth power of the local panel count.
For two half intervals with \(M_1=1,M_2=32\) and twelve panels in total, this gives four panels first and eight second. Cancelling their common factor \(L^5/2880\), the uniform six–six design has bound \(33/6^4\). The proposed four–eight design gives \(1/4^4+32/8^4=3/256\), about 46 percent of the uniform bound. Both designs use the same number of panels, integrate through the common interface, and rely on the same two derivative certificates. This does not guarantee that the actual integral error is reduced by the same factor, because the worst allowed derivatives need not occur everywhere. It quantifies the improved guarantee before sampling begins, entirely independently of a potentially aliased adaptive indicator.
Construct a false convergence test for adaptive quadrature
Integrate \(\sin^2(4\pi x)\) from zero to one using a trial Simpson panel and its two half-panels. All five evaluation points are multiples of 1/4. Predict the two estimates and the error inferred from their difference.

Read values from the plot
| Position in integration interval | True integrand | Interpolant from five trial samples |
|---|---|---|
| 0 | 0 | 0 |
| 0.25 | 1.4998e−32 | 0 |
| 0.5 | 5.999e−32 | 0 |
| 0.75 | 1.3498e−31 | 0 |
| 1 | 2.3996e−31 | 0 |
Change parameters · Construct a false convergence test for adaptive quadrature
Change one input at a time and compare the recalculated curves with the argument above. The browser evaluates this small model locally; the accompanying numerical values state its assumptions and reference checks. Reset restores the reference inputs, and the data can be downloaded as CSV.
Study the full derivation
Integrate the oscillations analytically and sample the envelope · Function approximation and numerical integration
A sensor model asks for many Fourier integrals of a slowly changing envelope. Direct trapezoids can return a full-scale signal where the true integral nearly cancels. Derive a Filon rule from exact oscillatory moments and find where it needs a different local model.