Numerical Quadrature
A definite integral is a linear functional: hand it a function and it returns a number. Numerical quadrature approximates that functional by something a computer can actually evaluate — a finite weighted sum of the integrand sampled at a handful of points, . Everything interesting lives in the two choices this formula exposes: where to place the nodes , and how heavily to weight each sample . Fix the nodes on an even grid and integrate the interpolating polynomial and you get the Newton–Cotes family — the trapezoidal rule, Simpson's rule, and their cousins. Let the nodes move too and demand the highest-degree polynomial be integrated exactly, and the optimal positions turn out to be the roots of an orthogonal polynomial: Gaussian quadrature, which doubles the accuracy for the same number of samples. Two threads run through the story. The first is degree of exactness — the largest polynomial degree a rule integrates without error — because Taylor's theorem guarantees a rule exact for high-degree polynomials is accurate on any smooth integrand. The second is error structure: Euler–Maclaurin shows the trapezoidal error is a clean series in even powers of the step size, and that one fact powers both Romberg extrapolation and the spectral accuracy of the trapezoidal rule on periodic integrands. For a physicist, quadrature is the benchmark that validates every asymptotic method (Laplace, stationary phase, steepest descent) and the engine that evaluates WKB phase integrals and Bohr–Sommerfeld actions when no closed form exists.
- Numerical quadrature replaces a definite integral by a weighted sum of integrand values at chosen nodes; the whole design problem is choosing the and .
- Newton–Cotes rules fix equally spaced nodes and integrate the Lagrange interpolant; the trapezoidal rule is second order, , and Simpson's rule is fourth order, .
- Gaussian quadrature frees the nodes too, reaching degree of exactness with only points by placing them at the roots of orthogonal polynomials — for the nodes are with weights .
- On the benchmark , four Gauss nodes give an error of , while the trapezoidal rule needs thousands of panels to match.
- Composite rules, Romberg extrapolation of the trapezoidal rule, and adaptive subdivision are the practical tools; for smooth periodic integrands the trapezoidal rule alone is spectrally accurate.
- Key idea: replace the integral — a linear functional — by a weighted sum of samples whose nodes and weights are tuned to integrate polynomials exactly to the highest possible degree; nodes reach degree for Newton–Cotes but for Gauss.
Replace the integral, a linear functional, by a weighted sum of integrand values whose nodes and weights are chosen to integrate polynomials exactly up to the highest possible degree; for nodes Newton–Cotes reaches degree (or by symmetry) while Gauss reaches .
Where this lives today
Quadrature is quietly everywhere in computational physics. The `quad` routine in every scientific library — SciPy, GSL, MATLAB — is built on QUADPACK, whose adaptive engine pairs a Gauss rule with a higher-order Gauss–Kronrod rule reusing the same nodes, so their difference gives a nearly free local error estimate that drives where the interval is subdivided. For extreme precision the double-exponential (tanh–sinh) transformation maps endpoint singularities to a smooth, exponentially decaying integrand on which the trapezoidal rule is spectrally accurate — the route to evaluating constants and lattice sums to thousands of digits. In semiclassical work, adaptive Gauss–Legendre quadrature evaluates the WKB phase integral and the Bohr–Sommerfeld action between turning points, a Gauss–Chebyshev rule taming the square-root singularity of . High-dimensional integrals — partition functions, Feynman loop integrals, lattice-QCD path integrals — are the open frontier: tensor-product Gauss rules and Smolyak sparse grids reach moderate dimension before the curse of dimensionality forces the switch to Monte Carlo. And because a good quadrature answer is essentially exact, it remains the gold standard against which Laplace's method, Watson's lemma, and stationary phase are validated in their large-parameter limits.
The physical picture
A quadrature rule is a recipe for weighing an integrand. You may look at only at a few sample points; each sample gets a weight saying how much "area" that reading is worth, and the weighted total estimates the integral. The trapezoidal rule fits a straight chord across each panel and adds the trapezoid areas — cheap, robust, second order. Simpson fits a little parabola through each triple and does dramatically better for the same spacing. The more faithfully the interpolant tracks the curve, the thinner the slivers you miss — and those slivers are the error.
Gaussian quadrature is the realization that equally spaced nodes throw away half your freedom. Fixing nodes on a grid leaves only the weights to tune — enough for degree . Let the nodes move too and you hold free numbers, enough for degree . The optimal positions are not arbitrary: they are exactly the roots of the degree- orthogonal polynomial for the interval's weight function — a deep bridge between integration and orthogonality. The payoff is enormous, as the second figure shows on one smooth benchmark: spend more evaluations and the trapezoidal rule crawls down as a power law, Simpson falls faster, and Gauss collapses fastest of all.
Why does smoothness matter so much? A rule of polynomial degree has an error proportional to a high derivative of — trapezoidal on , Simpson on , -point Gauss on . If those derivatives are bounded the error decays like a power of the step size; but a kink, a singularity, or rapid oscillation poisons the high derivatives and stalls convergence. That is the physicist's cue to switch tools: Gauss–Laguerre for a decaying tail, Gauss–Chebyshev for a square-root endpoint singularity, Filon's rule for a fast oscillation — the rule must match the integrand's analytic character, not just its shape.
The core equations
Every quadrature rule is one master formula with different nodes and weights. It approximates the integral, a linear functional, by a finite linear combination of samples, and its quality is the largest polynomial degree it reproduces exactly.
where: — quadrature nodes in ; — quadrature weights; — number of nodes; — integrand, sampled only at the nodes. Reading it: designing a rule means choosing the numbers , and its degree of exactness is the largest polynomial degree for which becomes . If the nodes are fixed, the natural weights come from replacing by the unique degree- polynomial through the samples and integrating it — each weight is the integral of a Lagrange basis function, computed once and reused.
where: the product is the -th Lagrange basis polynomial , with . Reading it: the weights depend only on the node positions, never on — which is what makes Newton–Cotes tables universal. The workhorse composite rules apply a low-order formula on every panel of a subdivided interval. Trapezoidal weights each interior node equally and halves the endpoints; Simpson alternates and from the local parabolic fits and needs an even number of panels.
where: — panel width; — number of equal panels ( even for Simpson); . Reading it: both cost one function value per node, yet Simpson buys two extra orders from the same samples — the parabola is accidentally exact for cubics. Gauss–Legendre abandons the grid: on it places its nodes at the roots of the Legendre polynomial and assigns the weights below, for exactness up to degree .
where: — Legendre polynomial of degree ; — its roots, all inside ; — the Gauss weights, all strictly positive. Reading it: weight positivity is a theorem, not luck, and it is what keeps the rule stable at high order where Newton–Cotes fails. The trapezoidal error is not a shapeless remainder — the Euler–Maclaurin formula exhibits it as a series in even powers of with coefficients built from boundary derivatives and Bernoulli numbers. This clean structure is the hinge of the whole subject.
where: — trapezoidal estimate at step ; — Bernoulli numbers; the bracket is a boundary-derivative difference. Reading it: only even powers appear, so extrapolation cancels them two orders at a time — and for a smooth periodic integrand every boundary difference vanishes, giving spectral accuracy. Romberg integration turns that even-power structure into an algorithm: a triangular table whose first column is trapezoidal estimates on halved grids, then Richardson-extrapolated across columns, each step killing the next even power of .
where: — trapezoidal estimate with panels; — the -accurate extrapolant; — the Richardson denominator cancelling the term. Reading it: the first extrapolation () is algebraically identical to composite Simpson, and each further column converges faster for smooth . (The Gauss error bound quantifying the degree- advantage — its error rides on with a factorially shrinking prefactor — is the last row of the limiting-cases table below.)
The goal is to show that once the nodes are fixed there is a canonical, integrand-independent choice of weights that makes the rule exact for every polynomial of degree , and that this choice is nothing more than the integral of each Lagrange basis function — so Newton–Cotes weights are computed once and stored, never recomputed per problem. We replace by its interpolant, integrate, and read off the weights.
Step 1. Interpolate: the unique polynomial of degree agreeing with at the nodes is , with and . Why: replacing by is the only step that introduces any error — and none at all when is a polynomial of degree .
Step 2. Integrate term by term: by linearity . Why: the constants slide outside, leaving only the fixed basis functions to integrate.
Step 3. Read off the weights , giving equation (1). Why: they depend only on the node placement, so for a fixed grid they are universal — the trapezoidal and Simpson patterns are just these integrals.
Step 4. Check exactness: if has degree then and the rule is exact. Why: this fixes the degree of exactness at (at least) , which node symmetry can lift by one, as Simpson shows. *Verified: for this gives (trapezoidal); for three equally spaced nodes, (basic Simpson).*
Go deeper · Derivation B · 1 minSimpson's rule and its fourth-order error
The aim is to derive the three-point Simpson formula by integrating a quadratic interpolant across two panels, and then to explain the pleasant surprise that its error is one order higher than the quadratic fit would suggest — the rule is exact for cubics too. We centre the algebra at the midpoint, integrate the local Taylor polynomial, watch the odd-power terms die by symmetry, and identify the surviving quartic term as the leading error.
Step 1. Place symmetric nodes , about and Taylor-expand about : . Why: centring makes odd over the symmetric interval, so half the terms vanish on integration.
Step 2. Integrate across : every odd power integrates to zero, leaving . Why: the vanishing of the odd terms, cubic included, is exactly why Simpson turns out exact for cubics.
Step 3. Eliminate with the central second difference , collapsing to . Why: this trades the unknown derivative for sampled values, giving the pattern plus its own correction.
Step 4. Collect the leftover: the surviving quartic terms combine to for the basic rule. Why: the local error is , a full order beyond the naive quadratic expectation.
Step 5. Composite it: summing blocks multiplies the per-block error by , giving . Why: fourth-order accuracy for zero extra samples — why Simpson is the default low-order rule. *Verified: basic and composite match Arfken–Weber Ch. 10 and Numerical Recipes §4.1; on Simpson with gives (error ).*
Go deeper · Derivation C · 1 minWhy the optimal Gauss nodes are roots of an orthogonal polynomial
The goal is to prove the central theorem of Gaussian quadrature: an -point rule is exact for all polynomials up to degree — twice what a fixed grid allows — precisely when the nodes are the zeros of the degree- orthogonal polynomial for the interval. We divide an arbitrary high-degree polynomial against , use orthogonality to annihilate one piece under the integral, and choose the nodes so the same piece vanishes in the sum, leaving a low-degree remainder the interpolatory weights integrate exactly.
Step 1. Divide: any of degree writes as with of degree , where is the Legendre polynomial. Why: division by a degree- divisor leaves a remainder below degree .
Step 2. Kill the quotient under the integral: since is orthogonal to every lower-degree polynomial, , so . Why: orthogonality says the quotient piece contributes nothing to the true integral.
Step 3. Kill it in the sum too: take the nodes as the roots of , so and . Why: at the zeros of the quotient term drops out pointwise.
Step 4. Close the loop: the interpolatory weights integrate the degree- remainder exactly, so — exact to degree . Why: this doubles exactness for free and forces the weights positive, the source of Gauss stability. *Verified: for , gives and , matching Abramowitz & Stegun Table 25.4.*
Limiting cases
How the error of the common rules scales, and which tool each regime calls for:
| Case | Result | Meaning |
|---|---|---|
| Composite trapezoidal | Second order ; cheapest and most robust, and spectrally accurate for smooth periodic integrands. | |
| Composite Simpson | Fourth order at no extra samples; the default general-purpose low-order rule. | |
| Gauss–Legendre ( nodes) | Exact to degree ; superb for smooth non-periodic integrands, weights all positive. | |
| Smooth periodic, full period | decays faster than any | Euler–Maclaurin boundary terms all cancel — the trapezoidal rule becomes spectrally accurate (the FFT's foundation). |
| Singular / semi-infinite | Use Gauss–Laguerre (weight ), Gauss–Hermite (), or Gauss–Chebyshev () to absorb the awkward factor analytically. |
Worked examples
1 · One integral, three rules (fully worked)
Evaluate the benchmark , whose exact value is , by composite trapezoidal (), composite Simpson (), and Gauss–Legendre, and compare the error per function evaluation.
Step 1. Trapezoidal, , . Sample at : . Then , an error of from five evaluations.
Step 2. Simpson, , same five samples. Apply the pattern: , an error of from the same five evaluations — two extra orders for nothing.
Step 3. Two-point Gauss. Map to by , so nodes land at . With weights and Jacobian : , an error of from just two evaluations — already beating trapezoidal's five.
Step 4. Three-point Gauss. Nodes map to with weights : , error from three evaluations; a fourth node reaches . Verdict: on a smooth integrand Gauss extracts far more accuracy per sample than any fixed-grid rule.
2 · The Romberg table (fully worked)
Build the Romberg triangle for the same integral from trapezoidal estimates on panels, and watch it converge to .
Step 1. First column — trapezoidal estimates : , , , . Only second order; the coarsest is off in the second decimal.
Step 2. First extrapolation — algebraically Simpson: , , . The term is gone; these are and the error drops a hundredfold.
Step 3. Second extrapolation, , killing the term: , . Third extrapolation, .
Step 4. Read the corner — the full triangle is
The bottom-right entry matches to eight decimals, from only nine function evaluations — the trapezoidal column alone would need on the order of panels for the same accuracy. Verified: each column's error falls by the predicted factor ( for column one, faster thereafter).
3 · Gauss exactness and its failure mode
Confirm that the two-point Gauss rule integrates a cubic exactly on , then quantify exactly how it fails on the first polynomial beyond its reach, .
Step 1. Cubic test. For the exact integral is . The rule gives ; the odd powers cancel between the symmetric nodes, leaving . Exact, as the degree- theorem promises.
Step 2. Quartic test. , but the rule gives , an error of .
Step 3. Match the error bound. The Gauss error formula (limiting-cases table) with , , and (constant, so the bound is attained) gives . The predicted and actual errors agree to every digit, confirming the error formula and the sharp cutoff at degree .
Physics of the portrait
Numerical integration is a thread running from Kepler's wine casks to modern lattice field theory, but its decisive idea — that moving the nodes doubles the accuracy — belongs to one person.
Origins · 1 minCarl Friedrich Gauss and how this was discovered
Carl Friedrich Gauss, already famous for number theory, least squares, and the orbit of Ceres, turned to numerical integration in an 1814 memoir with a disarmingly simple question: given a fixed budget of function evaluations, where should you place them? The Newton–Cotes tradition, inherited from Newton and Roger Cotes a century earlier, had always spaced the nodes evenly and solved for the weights, reaching degree of exactness . Gauss saw that the node positions were themselves free parameters, and that spending all degrees of freedom optimally lets an -point rule integrate polynomials up to degree — a factor-of-two leap that no cleverness with fixed nodes can match. His own derivation used continued fractions and hypergeometric series, but the modern reading is cleaner: the optimal nodes are the roots of the Legendre polynomials, and the rule's exactness follows directly from their orthogonality. Carl Gustav Jacobi made that connection explicit in 1826, and the framework generalizes seamlessly — Laguerre, Hermite, and Chebyshev weight functions each yield their own Gauss rule for the integrals of quantum mechanics, statistical physics, and scattering theory. It is a characteristic Gauss result: a practical recipe resting on a deep structural fact, so complete that two centuries later it remains the default engine inside every serious numerical library.
Going further
Texts. Stone & Goldbart, Mathematics for Physics (CUP 2009), Ch. 8 · Arfken, Weber & Harris, Mathematical Methods for Physicists, 7th ed., Ch. 10 · Riley, Hobson & Bence, Mathematical Methods for Physics and Engineering, 3rd ed., Ch. 27 · Press, Teukolsky, Vetterling & Flannery, Numerical Recipes, 3rd ed., §4 · Davis & Rabinowitz, Methods of Numerical Integration, 2nd ed.
Provenance. The trapezoidal error , the basic and composite Simpson errors and , and the two-point Gauss nodes and weights (, ) are standard and cross-checked against Arfken–Weber Ch. 10, Riley–Hobson–Bence Ch. 27, and Numerical Recipes §4. A verifier should recompute: (1) the Gauss moments to recover ; (2) the benchmark by trapezoidal (), Simpson (), and three-point Gauss (); (3) the Romberg corner ; (4) that two-point Gauss integrates exactly but errs on by , matching the error bound with .
Prerequisites. Taylor's Theorem and Polynomial Interpolation · Orthogonal Polynomials · Order Symbols and Gauge Functions. Leads to. Laplace's Method for Integrals · Method of Stationary Phase · Bohr–Sommerfeld Quantization · WKB Approximation.
Ask the tutor: Ask me to walk through the Romberg table for any integral of your choice, or to show exactly where an equally spaced rule breaks down and a Gauss rule saves the day.
What is the "degree of exactness" and why does it predict accuracy on non-polynomials?
The degree of exactness is the largest polynomial degree a rule integrates with zero error. It matters far beyond polynomials because of Taylor's theorem: any smooth integrand looks locally like its Taylor polynomial, so a rule that nails polynomials to degree leaves an error controlled by the first neglected derivative, . That is why the trapezoidal rule (exact to degree ) errs in , Simpson (degree ) in , and -point Gauss (degree ) in . Higher degree of exactness means the error rides on a higher derivative, a smaller effect for a smooth function — provided that derivative stays bounded.
When should I reach for Gauss quadrature instead of Simpson or Romberg?
Use a Gauss rule when the integrand is smooth over the whole interval and you cannot afford many evaluations — each is an expensive simulation, or you need a known smooth kernel to high precision. Its degree- exactness extracts the most accuracy per sample. Simpson and Romberg shine when samples are cheap and you want a built-in convergence check by halving the step, or when your data already sit on an equally spaced grid (Gauss samples at its own irrational nodes). For a singular or infinite endpoint, prefer the matching Gauss variant — Laguerre, Hermite, or Chebyshev — which folds the awkward weight function into the rule.
Why does the trapezoidal rule become spectacularly accurate for periodic functions?
Because its entire error is a sum of boundary terms. The Euler–Maclaurin formula writes the trapezoidal error as a series in whose coefficients are odd-derivative differences at the two endpoints, . For a smooth function periodic over the interval, the endpoints agree in every derivative, so every one of those differences is exactly zero. The whole power-law error series vanishes and what remains decays faster than any power of — spectral accuracy. This is why the trapezoidal rule, not Simpson, is the natural partner of Fourier analysis and the FFT.
Is Romberg integration really just Simpson in disguise?
Only the first extrapolation column is. Romberg's first column is trapezoidal estimates on successively halved grids; the first Richardson step, , cancels the leading error and is algebraically identical to composite Simpson. But it does not stop there — because the trapezoidal error contains only even powers of , each further column cancels the next even power (, then , and so on), producing rules of ever higher order that Simpson never reaches. Romberg is a whole tower of extrapolations of which Simpson is merely the ground floor, and for smooth integrands the deeper columns converge dramatically faster.
Why must the Gauss weights be positive, and does it matter?
It matters a great deal for stability, and it is provable directly: the weight equals for the Lagrange basis at the Gauss nodes — an integral of a square, hence positive. Positive weights make the rule a genuine weighted average of samples, so rounding errors in the cannot be amplified: the sum of the absolute weights equals . High-order Newton–Cotes rules lose exactly this property — some weights turn negative and large, so cancellation magnifies floating-point noise. Positivity is the quiet reason Gauss rules can be pushed to very high order while equally spaced rules cannot.
How do adaptive quadrature routines decide where to add points?
They estimate the local error and refine where it is largest. The standard trick, used in QUADPACK and hence in most `quad` functions, is to evaluate two rules of different order on the same panel — a Gauss rule and a Gauss–Kronrod rule that reuses the Gauss nodes and adds a few more. Their difference is a cheap, reliable proxy for the panel's error: if it exceeds the tolerance the panel is bisected and the procedure recurses on each half, otherwise the panel is accepted. This concentrates evaluations exactly where the integrand misbehaves — near a spike or a near-singularity — and leaves smooth stretches coarsely sampled, which is why adaptive routines handle real-world integrands so robustly.