Gauss–Legendre Quadrature
Move weighted interior nodes across an interval and test exactly which polynomial integrals two or three nodes reproduce.
By Riano · Published · Updated · Report a correction
Gauss–Legendre Quadrature
Gauss–Legendre quadrature is a high-precision numerical integration method that optimizes both the positions of interior evaluation nodes (the roots of Legendre polynomials Pn(t) on [-1, 1]) and their weights so an n-node rule integrates every polynomial of degree up to 2n - 1 with zero truncation error.
Worked Example: 2-Node Rule on a Quartic vs. Shifted 3-Node Rule
To integrate f(x) over an arbitrary interval [a, b], transform standard nodes ti ∈ [-1, 1] and weights ωi via the midpoint m = (a + b)/2 and signed half-width h = (b - a)/2:
xi = m + h·ti, wi = h·ωi, and Qn = Σ wif(xi).
- Quartic on
[-1, 1]with 2 nodes (m = 0,h = 1): The 2-node rule usest1,2 = ±1/√3andω1,2 = 1, which is exact through degree2(2) - 1 = 3. Forf(x) = x4(degree 4):f(±1/√3) = (1/3)2 = 1/9, soQ2 = 1·(1/9) + 1·(1/9) = 2/9 ≈ 0.2222222222222222.
The exact integral is∫-11 x4 dx = [x5/5]-11 = 2/5 = 0.4, leaving an exact truncation error of|2/9 - 2/5| = 8/45 ≈ 0.1777777777777778. - Quartic on shifted
[0, 2]with 3 nodes (m = 1,h = 1): The 3-node rule usest = -√(3/5), 0, +√(3/5)with weights5/9, 8/9, 5/9, exact up to degree2(3) - 1 = 5. Mapped toxi = 1 + ti, the sum of weights is5/9 + 8/9 + 5/9 = 2, and the quadrature reproduces the exact integral:Q3 = (5/9)[(1 - √(3/5))4 + (1 + √(3/5))4] + (8/9)(1)4 = (5/9)[2(1 + 6(3/5) + 9/25)] + 8/9 = 56/9 + 8/9 = 64/10 = 32/5 = 6.4, with zero error.
Interactive Experiment
Verify degree exactness and interval orientation in the Gauss–Legendre Quadrature interactive workspace:
- Start with Integrand = Quadratic, Nodes = 2, and Interval = Symmetric (
[-1, 1]). Confirm Quadrature and Exact integral both equal2/3with Absolute error = 0. - Switch Integrand to Quartic while keeping Nodes = 2. Observe that Quadrature drops to
2/9against Exact integral = 0.4 (error8/45). - Change Nodes to 3 and Interval to Shifted (
[0, 2]). Because degree 4 is below2(3) - 1 = 5, Quadrature matches32/5 = 6.4with zero error. - Select Integrand = Sextic with Nodes = 3 on Symmetric to see where the 3-node rule first incurs truncation error (
Q3 = 6/25 = 0.24vs.2/7, error8/175), then test Collapsed ([1, 1], zero weights) and Reversed ([1, -1], negative weights summing to-2).
Limitations and Assumptions
An n-node Gauss–Legendre rule guarantees algebraic exactness only for polynomials of degree at most 2n - 1. For degree 2n (such as x6 with 3 nodes), the positive leading error term f(2n)(ξ) causes the rule to underestimate convex even monomials on symmetric intervals. Furthermore, in IEEE-754 floating-point arithmetic, irrational nodes like ±1/√3 and ±√(3/5) introduce machine-epsilon roundoff on the order of 10-16; one must not confuse floating-point rounding with genuine quadrature truncation error.
References
The canonical abscissas (roots of Legendre polynomials), quadrature weights, and exactness remainder formulas for Gauss–Legendre rules are documented in the following reference:
- NIST Digital Library of Mathematical Functions (DLMF), Section 3.5(v): Gauss Quadrature — Tabulates standard interior nodes, weights on
[-1, 1], and degree2n - 1exactness theorems.
Experience it interactively
Adjust parameters, observe in real time, and build deep intuition with Riano’s interactive Gauss–Legendre Quadrature module.
Try Gauss–Legendre Quadrature on Riano →