Math Methods · Learn
Why does the gravity field of a slightly-flattened Earth, the electron orbitals in a hydrogen atom, and the most accurate possible numerical integration rule all involve the exact same set of polynomials?
Solve Laplace's equation $\nabla^2 V = 0$ in spherical coordinates and separate variables. The radial part is a power of $r$; the azimuthal part is sin/cos in the longitude angle; and the polar-angle part, with $x=\cos\theta$, satisfies:
Legendre's equation. Requiring the solution to stay finite at both poles ($x=\pm1$) forces $n$ to be a non-negative integer — and forces the solution to be a polynomial of degree $n$, $P_n(x)$.
Rather than solving the ODE by hand each time, $P_n$ satisfies a clean three-term recurrence (Bonnet's recursion):
So $P_2=\tfrac12(3x^2-1)$, $P_3=\tfrac12(5x^3-3x)$, and so on — each one built from the previous two with no integration needed. That's exactly how the lab computes them live.
Like Fourier's sines and cosines, different-order Legendre polynomials are orthogonal on $[-1,1]$:
which is exactly what lets you expand any reasonable function on a sphere as a sum $\sum_n c_n P_n(\cos\theta)$ and pull out each coefficient independently — the same projection trick as the Fourier series lab, just with a different orthogonal basis.
$P_n$ has exactly $n$ real roots, all inside $(-1,1)$. Those roots are not just a curiosity — they are precisely the sample points that make $n$-point Gaussian quadrature exact for any polynomial up to degree $2n-1$, far outperforming evenly-spaced sampling for the same number of function evaluations.
Pick an order and watch where the roots fall — those are the exact nodes a numerical-integration routine like scipy.integrate.quad uses under the hood. Open the lab →
Adrien-Marie Legendre introduced these polynomials in 1782 while studying the gravitational attraction of spheroids — planets aren't perfect spheres, and he needed a systematic way to expand the resulting correction to a $1/r$ potential. Three decades later, in 1814, Carl Friedrich Gauss showed that choosing the roots of $P_n$ as quadrature nodes gives far better numerical-integration accuracy than equally-spaced points for the same cost — turning a tool built for planetary shape into the backbone of modern numerical integration.
They're the polynomial solutions to Legendre's equation, which is the angular part of Laplace's equation in spherical coordinates. Demanding a solution that stays finite at the poles forces the order $n$ to be a non-negative integer, and the result is a family of polynomials built from a simple three-term recurrence.
They're the angular building blocks for any gravitational, electric, or magnetic field expanded around a sphere — Earth's gravity field, an atomic orbital — and their roots are exactly the optimal sample points for Gaussian quadrature, the most accurate way to numerically integrate a polynomial for a given number of evaluations.
Gauss derived the Gaussian quadrature rule by requiring it to integrate Legendre polynomials exactly, which forces the integration nodes to land exactly on the roots of the corresponding $P_n$. That's why the same special function shows up in both gravitational field expansions and numerical integration.
Starting from $P_0=1$ and $P_1=x$, every higher-order Legendre polynomial comes from the three-term recurrence $(n+1)P_{n+1}=(2n+1)xP_n-nP_{n-1}$ — no integration or differentiation required.
EngineeringCandy · Learn · the theory behind the playground