advanced28 min studyLesson 36 in Mathematics

Quadrature and adaptive integration

Approximate integrals with explicit rules, refinement estimates, and a clear distinction between an estimated and guaranteed error.

On this page

What you’ll understand

  • Interpret quadrature as integrating a local approximation.
  • Compute a refinement-based Simpson error estimate.
  • Explain why adaptive sampling can miss unresolved features.

An integral combines contributions across a whole domain, but numerical quadrature can inspect only finitely many points. The challenge is to spend those evaluations where they reveal the answer, while tracking what remains unseen. A quadrature rule converts sampled values into a weighted sum. An adaptive algorithm adds a decision about where to sample next. Both rely on assumptions about smoothness and scale. This lesson derives useful rules, follows a refinement calculation exactly, and asks what a returned tolerance actually certifies when the integrand contains a narrow peak or an oscillation.

Integrate an approximation you understand

The trapezoid rule replaces a function by a straight line across a panel and integrates that line. Simpson's rule instead integrates the quadratic interpolant through the endpoints and midpoint. Both are exact for certain low-degree polynomials, but exactness on a test class is not exactness for arbitrary functions. Composite rules divide the interval into panels and add their contributions. Panel widths, endpoint weights, and evaluation reuse must be handled consistently when comparing different resolutions.

For a sufficiently smooth function on a finite interval, the composite trapezoid error usually decreases quadratically with uniform step size, while composite Simpson error decreases to fourth order. Derivative bounds can turn these statements into rigorous estimates, but samples alone generally do not supply those bounds. Endpoint singularities, discontinuities, and rapidly changing derivatives can spoil the anticipated rate. Splitting at a known discontinuity or changing variables near a singular endpoint may be more effective than blindly applying a higher-order smooth formula.

S[a,b]=b−a6[f(a)+4f ⁣(a+b2)+f(b)]S[a,b]=\frac{b-a}{6}\left[f(a)+4f\!\left(\frac{a+b}{2}\right)+f(b)\right]
One Simpson panel integrates every polynomial of degree at most three exactly. Error-order statements for general functions additionally require smoothness; this formula alone is not an error certificate.↔ Scroll wide equations horizontally.

Use disagreement to decide where to refine

Compute a coarse Simpson approximation on a panel and a refined approximation from its two halves. If the leading fourth-order asymptotic error dominates, halving the mesh reduces that error by about sixteen. Their difference therefore estimates fifteen times the refined error, up to sign. This supplies a practical local error indicator without knowing the exact integral. Reusing shared values keeps the comparison economical, since only the new quarter points require fresh function evaluations.

An adaptive strategy subdivides panels whose estimated errors are too large and combines the accepted contributions. A global absolute-error budget must be distributed across subpanels or controlled by summing their indicators; allowing every subpanel the full budget would not prove the requested global tolerance. Relative tolerances also need an absolute floor when the final integral nearly cancels. Maximum evaluation counts and minimum panel sizes provide honest failure modes when the requested target cannot be resolved.

Efine≈Sfine−Scoarse15,I≈Sfine+EfineE_{\mathrm{fine}}\approx\frac{S_{\mathrm{fine}}-S_{\mathrm{coarse}}}{15},\qquad I\approx S_{\mathrm{fine}}+E_{\mathrm{fine}}
The signed correction follows from a leading fourth-order Simpson error. It is an asymptotic estimate, so unresolved structure or insufficient smoothness can invalidate it.↔ Scroll wide equations horizontally.

A tolerance request is not universal proof

Two rules can agree because both missed the same narrow peak. No finite set of unconstrained samples can rule out an arbitrarily large smooth bump hidden between them. Oscillatory cancellation creates another risk: many positive and negative contributions may leave a small total, making relative accuracy difficult even when local values are well resolved. If the function's structure is known, use that information through interval splitting, specialized oscillatory rules, analytic subtraction, or a transformation that exposes the relevant scale.

Validate with independent formulations when possible. Compare a changed variable, a different quadrature family, or a known limiting case, rather than merely tightening the same algorithm's tolerance. Distinguish the quadrature error from errors in the integrand itself, such as an inner nonlinear solve. Integrating an inaccurate function more carefully does not recover the intended integral. A useful result records the value, estimated error, evaluation count, assumptions, and whether the algorithm exhausted its budget. That is enough information to decide the next computation intelligently.

∣∫ab(f−f~) dx∣≤(b−a)∥f−f~∥∞\left|\int_a^b(f-\widetilde f)\,dx\right|\le(b-a)\|f-\widetilde f\|_\infty
For integrable functions with a finite uniform error bound on [a,b], this controls error from inaccurate integrand evaluation separately from the quadrature algorithm.↔ Scroll wide equations horizontally.

Refine Simpson's rule on a quartic

Approximate the integral of x⁴ on [0,1] with one Simpson panel and then two equal panels. Compare the error estimate with the exact integral 1/5.

  1. The coarse panel is [0+4(1/16)+1]/6=5/24≈0.2083333333. It is not exact, because the quartic exceeds Simpson's cubic exactness class.

  2. The refined composite rule has spacing h=1/4 and samples 0,1/256,1/16,81/256,1. Its weighted sum is (1/12)[1+4(82/256)+2(1/16)]=77/384≈0.2005208333.

  3. The signed correction is (77/384−5/24)/15=(−3/384)/15=−1/1920≈−0.0005208333. Adding it to the refined value gives exactly 0.2 in exact arithmetic.

  4. Here the refined error is exactly +1/1920, so the indicator has the correct magnitude. This perfect correction is special to the quartic's single relevant error term; it is not a universal guarantee for every smooth integrand.

The result

Refinement makes the error observable through a justified asymptotic model. The known integral independently checks the indicator and its sign.

Explore the model

Interactive lab

Interactive lab · function

Area as a target for numerical approximation

Set a=1 and move x from zero to one on y=a x². The lab reports the exact-form signed area a x³/3 from zero to x; at one it is 1/3. Predict why Simpson's rule is exact for this quadratic, then change a. The lab does not run quadrature, display panels, or adapt a mesh, and the quartic example is not plotted.

Area as a target for numerical approximationThis lab uses only y = ax². Playback traces the curve within the fixed integration interval from 0 to x; it does not estimate numerical error or change the chosen point. Current readings: y at chosen x: 0.608; Tangent slope · 2ax: 1.35; Signed area · ax³/3: 0.182. All parameters are adjustable with the labeled controls below.−2.4−1.201.22.4−9−4.504.59xy(x, ax²)
y = ax²TangentSigned integral
y at chosen x
0.608
Tangent slope · 2ax
1.35
Signed area · ax³/3
0.182
t = 0 s

This lab uses only y = ax². Playback traces the curve within the fixed integration interval from 0 to x; it does not estimate numerical error or change the chosen point. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.

Look forUse an analytically known area to validate an integration routine before trusting its error estimate on unfamiliar data.

Check your understanding

Coarse and refined quadrature estimates agree closely. What can still go wrong?

Try it yourself

Apply one Simpson panel to x³ on [0,2]. Compute the exact integral separately.

Take a moment to make a prediction or work it out on paper. Open a hint when you need one.

Give me a hint

The midpoint is one and the interval length is two.

Compare with the solution

Simpson gives (2/6)[0+4(1)+8]=4. The antiderivative x⁴/4 gives 16/4=4. Agreement follows from cubic exactness in exact arithmetic; it does not require a small interval or an asymptotic limit.

Take it with you

  • Quadrature rules integrate specific local approximations.
  • Adaptive indicators rely on an error model and require global budget accounting.
  • Independent structure and validation are essential when sampling may miss important features.

Read further

Original sources and deeper explanations to follow at your own pace.

Optional progress, saved in this browser when available. Revisit any lesson at any time.

Lesson not marked complete.