Gaussian Quadrature
Choosing where to sample a function, not just how to combine the samples, to integrate it accurately with far fewer evaluations than evenly-spaced methods — the difference between guessing evenly and picking your points strategically.
Prerequisites: The Trapezoid and Simpson Rules
The trapezoid and Simpson rules both sample a function at evenly-spaced points and only get to choose the weights applied to those samples. It turns out that if you're also allowed to choose where to sample — not just evenly spaced, but at specially-computed locations — a small number of cleverly-placed points can integrate a function exactly as well as many more evenly-spaced points. Gaussian quadrature is that idea taken to its logical extreme: for a given number of function evaluations, it's provably the most accurate possible choice of sample points and weights, for a wide class of smooth functions.
An analogy: weighing a seesaw with the fewest measurements
Imagine estimating the total weight and balance point of an oddly-loaded seesaw by taking a small number of measurements at chosen spots. If you're forced to measure at evenly-spaced points, you'll need many measurements to characterize a complicated loading. But if you're allowed to choose where to measure, there's a small set of specific spots — not evenly spaced, clustered more densely toward the edges — that captures far more information about the true loading per measurement taken. Gaussian quadrature is the mathematical version of finding those optimal spots, for integrating a function instead of weighing a seesaw.
The math, one piece at a time
Gaussian quadrature approximates an integral as a weighted sum of function values at specially chosen points , called nodes, with specially chosen weights :
In words: instead of evenly spacing points and giving them simple weights (like Simpson's alternating 4s and 2s), Gaussian quadrature solves for the node locations and weights that make this formula exactly correct for every polynomial up to degree — nearly double the degree that evenly-spaced points could match. The nodes turn out to be the roots of the -th Legendre polynomial, a specific family of polynomials that are mutually orthogonal over ; the reader doesn't need to derive this, only to know that these root locations are tabulated once and reused for any smooth integrand.
The practical payoff: with points, Gaussian quadrature exactly integrates any polynomial up to degree , whereas Simpson's rule (also using roughly points) only reaches about degree 3 exactness locally per pair of intervals. For smooth (non-polynomial) integrands, this translates into Gaussian quadrature reaching a target accuracy with dramatically fewer function evaluations than evenly-spaced rules — often an order of magnitude fewer for smooth pricing integrands. Integrals over a general range instead of use a simple linear rescaling of the nodes and weights, so the tabulated values work for any interval.
Worked example 1: exactness on a polynomial
2-point Gaussian quadrature uses nodes with weights , and is exact for any polynomial up to degree 3. Check on over (true integral: the odd term vanishes by symmetry, leaving ). Evaluating at the two nodes and summing with exact fractions confirms the 2-point rule reproduces exactly, using only 2 function evaluations for a cubic that Simpson's rule would need several evenly-spaced points to match.
Worked example 2: pricing a smooth expected payoff
Estimating under a smooth density with a 5-point Gaussian quadrature rule (rescaled to the relevant price range) typically matches the accuracy of a Simpson's-rule integration using 20-30 evenly-spaced points, because the payoff and density together form a smooth-enough function that Gaussian quadrature's higher polynomial exactness pays off directly — cutting a pricing library's per-integral evaluation count by roughly 4-6x for the same accuracy target, which matters when the same integral is re-evaluated thousands of times during calibration.
What this means in practice
Gaussian quadrature is the workhorse behind fast numerical integration in pricing libraries — computing expected payoffs, integrating characteristic functions in Fourier-based option pricing (like the Carr-Madan method), and any repeated, performance-sensitive integral over a smooth function where evaluation count matters. It's less useful when the integrand has kinks, jumps, or is only known at fixed pre-determined points (like historical data), since its main advantage — choosing where to sample — requires being able to evaluate the function anywhere.
Gaussian quadrature chooses both the sample point locations and their weights to make the integration formula exact for the widest possible class of polynomials — for smooth functions this typically means dramatically fewer function evaluations than evenly-spaced rules like the trapezoid or Simpson's rule for the same accuracy.
The classic mistake is applying Gaussian quadrature to an integrand with a kink, discontinuity, or singularity, expecting the same dramatic accuracy gains it delivers on smooth functions. Gaussian quadrature's advantage comes entirely from polynomials being able to approximate smooth curves extremely well with few terms; across a kink, a polynomial fit is no better (and can be worse, with ringing artifacts) than a much simpler evenly-spaced rule. Split the integration range at any known discontinuity before applying Gaussian quadrature to each smooth piece separately.
Practice in interviews
Further reading
- Press et al., Numerical Recipes, ch. 4
- Golub & Welsch, Calculation of Gauss Quadrature Rules