Legendre Polynomials Calculator P_n(x)

Legendre polynomials P_n(x) calculator: Bonnet three-term recurrence, explicit coefficients, roots (Gauss-Legendre nodes), derivatives and L^2 normalization.

Calculation parameters
Was this calculator useful?

Legendre polynomials

Legendre polynomials P_n(x), introduced by Adrien-Marie Legendre in 1782 while studying the gravitational potential of an ellipsoid, are a sequence of orthogonal polynomials on [-1, 1] with weight w(x) = 1. They are fundamental in mathematical physics, potential theory, quantum mechanics and numerical analysis.

Definition via differential equation

P_n(x) is the unique polynomial of degree n solving the Legendre differential equation:

(1 - x^2) * P_n''(x) - 2x * P_n'(x) + n(n+1) * P_n(x) = 0

normalized by P_n(1) = 1. This equation arises from separating variables in Laplace's equation in spherical coordinates: the angular solutions in theta are exactly P_n(cos(theta)).

Rodrigues' formula

Olinde Rodrigues (1816) provides an explicit definition:

P_n(x) = (1 / (2^n * n!)) * d^n/dx^n [(x^2 - 1)^n]

Expanding (x^2 - 1)^n and differentiating n times yields a degree-n polynomial with alternating parity: P_n is even if n is even, odd if n is odd.

Bonnet's three-term recurrence

The most efficient computation method uses the three-term recurrence:

(n+1) * P_{n+1}(x) = (2n+1) * x * P_n(x) - n * P_{n-1}(x)

with P_0(x) = 1, P_1(x) = x. Proved by Pierre Ossian Bonnet (1844), this recurrence evaluates P_n in O(n) operations with O(1) memory. Numerically stable for |x| <= 1.

First polynomials

  • P_0(x) = 1
  • P_1(x) = x
  • P_2(x) = (3x^2 - 1) / 2
  • P_3(x) = (5x^3 - 3x) / 2
  • P_4(x) = (35x^4 - 30x^2 + 3) / 8
  • P_5(x) = (63x^5 - 70x^3 + 15x) / 8
  • P_6(x) = (231x^6 - 315x^4 + 105x^2 - 5) / 16

Orthogonality property

Polynomials are orthogonal on [-1, 1]:

integral_-1^1 P_m(x) * P_n(x) dx = 2/(2n+1) if m = n, 0 otherwise

This makes them a natural basis for function expansion: f(x) = Sigma a_n * P_n(x) with a_n = (2n+1)/2 * integral f * P_n dx. Analogous to Fourier series on [-1, 1] with uniform measure.

Five calculator modes

  1. Single evaluation: P_n(x) via Bonnet recurrence.
  2. Sequence: list P_0..P_n for single x.
  3. Explicit coefficients: polynomial P_n(x) = Sigma a_k * x^k.
  4. Roots: all n roots in (-1, 1), Gauss-Legendre nodes.
  5. Derivative P_n'(x): via identity (x^2-1) P_n'(x) = n(x P_n - P_{n-1}).

Gauss-Legendre quadrature

The most important application: nodes x_k (roots of P_n) and weights w_k = 2 / ((1 - x_k^2) * P_n'(x_k)^2) approximate integrals:

integral_-1^1 f(x) dx ~ Sigma_{k=1}^{n} w_k * f(x_k)

exact for polynomials of degree <= 2n-1. Numerically optimal method for quadrature on finite intervals without singularities. Nodes and weights tabulated for n up to 100; beyond, Newton on the recurrence is used.

Applications

  • Quantum mechanics: spherical harmonics Y_l^m, hydrogen atom.
  • Potential theory: multipole expansion in electrostatics and gravitation.
  • Numerical analysis: Gauss-Legendre quadrature.
  • Electromagnetism: series expansion for axial-symmetry potentials.
  • Statistical mechanics: angular parts of spherical partition functions.
  • Statistics: non-parametric tests based on P_n.

History of Legendre polynomials

The polynomials were introduced by the French mathematician Adrien-Marie Legendre in 1782, while studying the gravitational attraction exerted by celestial bodies of ellipsoidal shape. In trying to expand the gravitational potential at a distance in a series, Legendre came upon a family of polynomials with remarkable orthogonality properties. Their role became even more central with the study of spherical harmonics and Laplace's equation, fundamental in mathematical physics. Today Legendre polynomials are an indispensable tool in electrostatics, quantum mechanics, geodesy and numerical analysis, and their roots provide the optimal nodes of Gauss-Legendre quadrature. From an 18th-century celestial mechanics problem grew one of the most used families of special functions in science.

The generating function and notable properties

One of the most elegant features of the Legendre polynomials is their generating function: 1/√(1 − 2xt + t²) = Σ Pₙ(x)tⁿ. Expanding this expression as a power series in the parameter t, the coefficients are exactly the Legendre polynomials. This formula is the same one that appears naturally in the expansion of the Coulomb and gravitational potential, explaining why the polynomials emerge in physics. Among the other notable properties: every Pₙ equals 1 at x = 1 and (−1)ⁿ at x = −1; the polynomials have definite parity, even for even n and odd for odd n; and all n roots of Pₙ are real, distinct and contained in the open interval (−1, 1).

Legendre polynomials in physics

Legendre polynomials are ubiquitous in mathematical physics. In electrostatics and gravitation they provide the multipole expansion of the potential of a charge or mass distribution, separating the monopole, dipole, quadrupole and so on contributions. They are the angular part of the spherical harmonics, solutions of Laplace's equation in spherical coordinates, which describe the vibration modes of a sphere and energy levels. In quantum mechanics they appear in the solution of the hydrogen atom and in the theory of angular momentum, where the orbital quantum numbers correspond to the degree of the polynomial. They also appear in geodesy to model the Earth's gravitational field and in optics for lens aberrations.

Updated July 2026

Frequently Asked Questions

What are Legendre polynomials?

They are a family of orthogonal polynomials Pₙ(x), solutions of Legendre's differential equation, defined on the interval [−1, 1]. The first are P₀=1, P₁=x, P₂=(3x²−1)/2, P₃=(5x³−3x)/2. They are fundamental in mathematical physics, where they appear in spherical harmonics, the multipole expansion of potentials and numerical quadrature. They form an orthogonal basis for functions on the interval.

What is Bonnet's three-term recurrence?

It is the relation (k+1)Pₖ₊₁(x) = (2k+1)x·Pₖ(x) − k·Pₖ₋₁(x), which lets each Legendre polynomial be computed from the two preceding ones, starting from P₀=1 and P₁=x. It is the most efficient and stable method to generate the sequence: it avoids computing the derivatives of Rodrigues' formula and lets Pₙ(x) be evaluated quickly for any degree n and argument x.

What is Rodrigues' formula?

It is an explicit formula for the Legendre polynomials: Pₙ(x) = (1/(2ⁿ·n!))·dⁿ/dxⁿ[(x²−1)ⁿ]. In other words, you differentiate the polynomial (x²−1)ⁿ n times and normalise. It is theoretically elegant and useful for proving the polynomials' properties, but impractical for high-degree numerical computation, where Bonnet's recurrence is preferred.

What does it mean that the polynomials are orthogonal?

It means that the integral of the product of two Legendre polynomials of different degree over the interval [−1, 1] is zero: ∫Pₘ(x)Pₙ(x)dx = 0 for m ≠ n. For m = n the integral equals 2/(2n+1). This orthogonality makes them an ideal basis for expanding a function in a series, analogously to Fourier series with sines and cosines, and is the key to their usefulness in physics and numerical analysis.

Why are the roots the nodes of Gauss-Legendre quadrature?

Because by choosing as evaluation points the n roots of Pₙ, the resulting quadrature formula integrates exactly all polynomials up to degree 2n−1, the maximum possible with n points. This optimal property follows directly from the orthogonality of the Legendre polynomials. The roots are all real and lie in (−1, 1), and around them the weights of Gaussian quadrature are built, one of the most accurate numerical methods.

What is the value of Pₙ at the endpoints of the interval?

Every Legendre polynomial equals exactly 1 at the point x = 1: Pₙ(1) = 1 for every n. At the opposite endpoint it equals Pₙ(−1) = (−1)ⁿ, that is 1 for even n and −1 for odd n. This property reflects the parity of the polynomials: Pₙ is an even function if n is even and odd if n is odd. They are notable values, often used to check computations and in the boundary conditions of physical problems.

What is the generating function of the polynomials?

It is the expression 1/√(1 − 2xt + t²) = Σ Pₙ(x)tⁿ, which generates all the Legendre polynomials as the coefficients of the expansion in powers of t. It is notable because it is the same function that appears in the expansion of the gravitational and electrostatic potential at a distance: hence the polynomials emerge naturally in physics, in the multipole expansion and in computing the potentials of charge or mass distributions.

Who introduced the Legendre polynomials?

They were introduced by Adrien-Marie Legendre in 1782, while studying the gravitational potential of ellipsoidal celestial bodies. Trying to expand the attraction at a distance in a series, he came upon this family of orthogonal polynomials. Their role grew with the study of spherical harmonics and Laplace's equation. Today they are a standard tool in physics, geodesy, quantum mechanics and numerical analysis.

Comments (0)

No comments yet. Be the first!