Calculus & Analysis

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).

  1. Quartic on [-1, 1] with 2 nodes (m = 0, h = 1): The 2-node rule uses t1,2 = ±1/√3 and ω1,2 = 1, which is exact through degree 2(2) - 1 = 3. For f(x) = x4 (degree 4):
    f(±1/√3) = (1/3)2 = 1/9, so Q2 = 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.
  2. Quartic on shifted [0, 2] with 3 nodes (m = 1, h = 1): The 3-node rule uses t = -√(3/5), 0, +√(3/5) with weights 5/9, 8/9, 5/9, exact up to degree 2(3) - 1 = 5. Mapped to xi = 1 + ti, the sum of weights is 5/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:

  1. Start with Integrand = Quadratic, Nodes = 2, and Interval = Symmetric ([-1, 1]). Confirm Quadrature and Exact integral both equal 2/3 with Absolute error = 0.
  2. Switch Integrand to Quartic while keeping Nodes = 2. Observe that Quadrature drops to 2/9 against Exact integral = 0.4 (error 8/45).
  3. Change Nodes to 3 and Interval to Shifted ([0, 2]). Because degree 4 is below 2(3) - 1 = 5, Quadrature matches 32/5 = 6.4 with zero error.
  4. Select Integrand = Sextic with Nodes = 3 on Symmetric to see where the 3-node rule first incurs truncation error (Q3 = 6/25 = 0.24 vs. 2/7, error 8/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:

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 →

More in Calculus & Analysis