Gaussian Quadrature
Gaussian Quadrature: Choosing the Nodes as Well as the Weights
The idea
Every quadrature rule approximates an integral by a weighted sum of function values,
∫ab f(x) dx ≈ ∑ wi f(xi).
Rules such as the trapezoidal, midpoint and Simpson rules fix the nodes in advance, usually equally spaced, and then choose the weights to make the rule exact for polynomials of as high a degree as possible. Those rules and their composite and extrapolation variants belong to the sibling concepts.
Gaussian quadrature asks a different question: what if the nodes are free as well? An n-point rule then has 2n unknowns, n weights and n nodes, so 2n conditions can be imposed.
Demanding exactness for 1, x, x2, …, x2n−1 gives exactly 2n equations, and the resulting rule is exact for every polynomial of degree at most 2n − 1. That is the whole idea, and everything else follows from it.
Two function evaluations buy exactness up to cubics; three buy exactness up to quintics.
Standard low-order rules on [−1, 1]
Gauss–Legendre rules are stated on the reference interval [−1, 1]:
n | Nodes | Weights | Exact to degree |
|---|---|---|---|
1 | 0 | 2 | 1 |
2 | ±1/√3 = ±0.577350 | 1, 1 | 3 |
3 | 0, ±√(3/5) = ±0.774597 | 8/9, 5/9, 5/9 | 5 |
The nodes are the roots of the Legendre polynomials, which is where the name comes from, and they always lie strictly inside (−1, 1), never at the endpoints. They are selected by moment exactness rather than prescribed as an endpoint-including grid.
For orders n ≥ 4 their adjacent spacing is nonuniform and becomes denser toward the endpoints as n grows; the n = 3 nodes 0 and ±√(3/5) in the table above happen to be equally spaced.
Excluding the endpoints is a practical advantage when the integrand is awkward or undefined at an endpoint.
Moving to a general interval
A rule stated on [−1, 1] is transferred to [a, b] by the affine substitution
x = ((b − a)t + a + b)/2, dx = ((b − a)/2) dt,
so that
∫ab f(x) dx = ((b − a)/2) ∫−11 f(x(t)) dt ≈ ((b − a)/2) ∑ wi f(x(ti)).
Two things must both happen: each reference node ti is mapped to its position xi in [a, b], and the whole sum is multiplied by the Jacobian factor (b − a)/2. Omitting the Jacobian is the most frequent error in a first calculation, and it is easy to catch, apply the rule to f(x) = 1, where the answer must be b − a.
Worked example. Evaluate ∫15 x3 dx with the two-point rule.
Here (b − a)/2 = 2 and the midpoint is 3, so the nodes are x = 3 ± 2/√3 = 4.15470 and 1.84530. Then f values are 4.154703 = 71.7165 and 1.845303 = 6.2835, summing to 78.0000, and multiplying by the Jacobian 2 gives 156.000. The exact value is (54 − 14)/4 = 624/4 = 156, so the rule is exact, as it must be, since x3 is a cubic and the two-point rule is exact through degree 3.
Where exactness stops
For an n-point Gauss–Legendre rule, degree 2n − 1 is the highest degree through which all polynomials are guaranteed exact. An individual polynomial of higher degree can still be exact.
For example, the symmetric three-point rule integrates x7 over [−1, 1] exactly: the integral is 0 by oddness, and the weighted values at the paired nodes cancel while the center contributes 0.
The guarantee does not extend to every polynomial above degree 5.
For x6, the exact integral is 2/7 = 0.285714. The three-point rule gives 2 × (5/9)(3/5)3 = 6/25 = 0.240000, so the signed error (rule minus exact) is 0.240000 − 0.285714 = −0.045714. A four-point rule, guaranteed exact through degree 7, returns 2/7 for this example.
Each added point raises the guaranteed degree by two; the x6 calculation is one case where a higher-degree polynomial is not exact.
This is the practical meaning of the degree of exactness. It guarantees exactness for every polynomial through the stated degree; it does not predict whether a particular higher-degree polynomial or non-polynomial integrand will be exact.
Reading the error
For the n-point Gauss–Legendre rule on [a, b], write the exact integral as the rule plus an error term:
∫ab f(x) dx = ∑ wi f(xi) + E, where E = [(b − a)2n+1 (n!)4 / ((2n + 1)((2n)!)3)] f(2n)(ξ) for some ξ in (a, b).
Settle that convention before using the formula: E is the exact value minus the rule's value, so a positive E means the rule underestimates. Reversing it reverses the sign you infer for f(2n)(ξ) from an observed error.
The exact constant matters less than the two things the formula tells you. First, the error involves the 2n-th derivative, so it vanishes identically whenever f is a polynomial of degree below 2n, the degree-of-exactness statement, recovered from the error term.
Second, it carries a factor (b − a)2n+1, so halving the interval reduces the error bound by a factor of 22n+1, which is 32 for the two-point rule. This is why the rule is applied on subintervals when high accuracy is wanted.
Two cautions. The bound is useless if f is not smooth enough to have a bounded 2n-th derivative on the interval, Singularities or sharp features can reduce Gaussian quadrature's accuracy advantage, while interior nodes still avoid evaluating an undefined endpoint value.
And ξ is unknown, so the formula gives a bound rather than the error itself; a practical error estimate usually comes from comparing rules of different orders.
Mark Yourself Question
- Grab a piece of paper and try this problem yourself.
- When you're done, check the "I have answered this question" box below.
- View the solution and report whether you got it right or wrong.
Answer all four parts.
- State the nodes and weights of the two-point Gauss–Legendre rule on [−1, 1], and the degree of polynomials it integrates exactly.
- Verify directly that the rule is exact for f(x) = x3 and for f(x) = x2 on [−1, 1], showing the arithmetic.
- Write the substitution that transfers a rule from [−1, 1] to a general interval [a, b], and state the two separate adjustments it requires.
- Explain why Gaussian nodes are determined by moment conditions rather than prescribed as an endpoint-including uniform grid, and give one practical advantage of their lying strictly inside the interval.
Mark Yourself Question
- Grab a piece of paper and try this problem yourself.
- When you're done, check the "I have answered this question" box below.
- View the solution and report whether you got it right or wrong.
Use the two-point Gauss–Legendre rule to evaluate
∫02 x3 dx.
Show the transformed nodes and the Jacobian factor you use. Give the quadrature value to four decimal places, compare it with the exact value, and explain whether the agreement you find was predictable in advance.
Give your answer in same units as the integrand times x; here dimensionless.