Legendre & Orthogonal Polynomials
Legendre, Chebyshev, Hermite and Laguerre polynomials are families that are mutually orthogonal under a weighted inner product. Learn their generating equations, Rodrigues' formula, recurrences, orthogonality integrals, and why they power Gaussian quadrature, least-squares fitting, spectral methods, spherical potentials and quantum mechanics.
Just as the vectors î, ĵ, k̂ are perpendicular, certain polynomial families are 'perpendicular' in the sense that the integral of their product is zero. That makes them ideal basis functions: coefficients can be found one at a time, and truncating the series gives the best approximation.
Legendre polynomials appear when solving Laplace's equation in spherical coordinates (gravitational and electric potentials), and their roots give the nodes of Gauss–Legendre quadrature — the integration rule inside nearly every finite-element code.
An analogy
Orthogonal polynomials are like the independent sliders of a graphic equaliser: moving one does not disturb the others, so you can tune each component of a function separately.
What 'orthogonal functions' means
For vectors, orthogonal means a·b = 0. For functions, the dot product becomes an integral: ⟨f, g⟩ = ∫ f g w dx. Two functions are orthogonal if that integral is zero. sin x and sin 2x on [0, π] are orthogonal; so are P₂ and P₃ on [−1, 1].
The main families
Each family is orthogonal on its own interval with its own weight — pick the one matching your problem's domain.
- Legendre Pₙ: [−1, 1], w = 1 — spherical potentials, Gauss quadrature
- Chebyshev Tₙ: [−1, 1], w = 1/√(1−x²) — minimax approximation, filter design
- Hermite Hₙ: (−∞, ∞), w = e^(−x²) — quantum oscillator, Gaussian statistics
- Laguerre Lₙ: [0, ∞), w = e^(−x) — hydrogen atom, decay integrals
Best approximation
Truncating f = Σ aₙPₙ after N terms gives the least-squares-best polynomial of degree N. Chebyshev truncation is nearly minimax (smallest maximum error), avoiding the Runge oscillations of equally-spaced interpolation — which is why Chebyshev nodes are used for interpolation.
Sturm–Liouville origin and Gaussian quadrature
All these families are eigenfunctions of Sturm–Liouville problems, which guarantees orthogonality and completeness. Placing n quadrature points at the roots of the n-th orthogonal polynomial makes the rule exact for polynomials of degree 2n − 1 — double what n arbitrary points can achieve.
Spectral methods in CFD expand the solution in Chebyshev or Legendre polynomials, giving exponential convergence for smooth problems.
Formulas
- Legendre equation:
(1 − x²)y″ − 2xy′ + n(n + 1)y = 0 - Rodrigues' formula:
Pₙ(x) = (1 / 2ⁿn!) dⁿ/dxⁿ (x² − 1)ⁿ - First few:
P₀ = 1, P₁ = x, P₂ = (3x² − 1)/2, P₃ = (5x³ − 3x)/2 - Bonnet recurrence:
(n + 1)Pₙ₊₁ = (2n + 1)x Pₙ − n Pₙ₋₁ - Orthogonality:
∫₋₁¹ Pₘ Pₙ dx = 2/(2n + 1) · δₘₙ - Chebyshev:
Tₙ(cos θ) = cos nθ, weight 1/√(1 − x²) - Series coefficient:
f = Σ aₙPₙ, aₙ = (2n + 1)/2 ∫₋₁¹ f Pₙ dx - Gauss–Legendre:
∫₋₁¹ f dx ≈ Σ wᵢ f(xᵢ), xᵢ = roots of Pₙ; exact to degree 2n − 1
Worked example: Rodrigues' formula
Given: n = 2
Find: P₂(x).
- (x² − 1)² = x⁴ − 2x² + 1
- d²/dx² = 12x² − 4
- ÷ (2²·2!) = 8
Answer: P₂ = (3x² − 1)/2
Worked example: Gauss 2-point rule is exact for cubics
Given: ∫₋₁¹ (x³ + x²) dx, nodes ±1/√3, weights 1
Find: Compare with exact.
- Exact = 0 + 2/3
- Gauss: f(−0.5774) + f(0.5774) = 2 × (1/3)
Answer: Both give 0.6667 — exact.
Worked example: Legendre expansion
Given: f(x) = x² on [−1, 1]
Find: Expansion in Pₙ.
- x² = a₀P₀ + a₂P₂
- P₂ = (3x² − 1)/2 → x² = (2P₂ + 1)/3
Answer: x² = ⅓P₀ + ⅔P₂
Gauss–Legendre quadrature and orthogonality
import numpy as np
f = lambda x: np.cos(x)
exact = 2 * np.sin(1)
for n in (1, 2, 3, 4):
x, w = np.polynomial.legendre.leggauss(n) # nodes = roots of P_n
I = np.sum(w * f(x))
print(f"n={n}: nodes={np.round(x, 4)} I={I:.8f} error={abs(I - exact):.1e}")
# Orthogonality check: integral of P2*P3 and P3*P3 on [-1, 1]
P2 = np.polynomial.legendre.Legendre.basis(2)
P3 = np.polynomial.legendre.Legendre.basis(3)
print("int P2*P3 =", round((P2 * P3).integ()(1) - (P2 * P3).integ()(-1), 10))
print("int P3*P3 =", round((P3 * P3).integ()(1) - (P3 * P3).integ()(-1), 6), " (2/7 =", round(2/7, 6), ")")
# n=1: nodes=[0.] I=2.00000000 error=3.2e-01
# n=2: nodes=[-0.5774 0.5774] I=1.67582366 error=7.1e-03
# n=3: nodes=[-0.7746 0. 0.7746] I=1.68300355 error=6.2e-05
# n=4: nodes=[-0.8611 -0.34 0.34 0.8611] I=1.68294169 error=2.8e-07
# int P2*P3 = 0.0
# int P3*P3 = 0.285714 (2/7 = 0.285714 )With just 4 function evaluations Gauss–Legendre reaches 10⁻⁷ accuracy — Simpson's rule would need about 40. This is why FEM element integrals use Gauss points.
Common mistakes
- Wrong: Using Gauss nodes on [a, b] without mapping. — Right: x = (b−a)/2·ξ + (a+b)/2 and multiply by (b−a)/2.
- Wrong: Ignoring the weight function. — Right: Chebyshev orthogonality needs 1/√(1−x²).
- Wrong: High-degree equally spaced interpolation. — Right: Use Chebyshev nodes to avoid Runge oscillation.
Applications
- FEM: Gauss–Legendre points integrate element stiffness matrices.
- Geophysics: Earth's gravity field expanded in Legendre/spherical harmonics.
- Signal processing: Chebyshev filters use Tₙ for equiripple responses.
- Quantum & optics: Hermite–Gauss laser modes; hydrogen wavefunctions (Laguerre).
Key takeaways
- Orthogonal = zero weighted integral of product.
- Each family has its interval and weight.
- Roots give optimal quadrature nodes.
- Truncated series = best approximation.
Going further
- Spherical harmonics: Yₗᵐ built from associated Legendre functions.
- Clenshaw–Curtis: Chebyshev-based quadrature via FFT.
- Polynomial chaos: Hermite expansions for uncertainty quantification.