Orthogonal Polynomials (3D)

Each degree is a ribbon standing on the table: see the family, the target function, the partial sum and the zeros together.

Presets

Playback

Function and basis

Probe and sweep

Camera

Layers

Quality

Model check

The science

What this page shows

A family of orthogonal polynomials P0, P1, ... P12 and the best approximation of a chosen function by the first N of them. The coefficients are computed by numerical integration, not read from a table, and every number on the page is recomputed when you change the family or the function.

Orthogonality

Two functions are orthogonal for a weight w(x) on an interval when <f,g> = ∫ f(x) g(x) w(x) dx = 0. The four families here are Legendre (w = 1 on [-1,1]), Chebyshev of the first kind (w = 1/√(1-x²)), Hermite (physicists', w = e-x² on the whole line) and Laguerre (w = e-x on [0, ∞)). Each obeys a three-term recurrence, for example (n+1) Pn+1 = (2n+1) x Pn - n Pn-1 for Legendre, and has norm hn = <Pn,Pn>: 2/(2n+1), π or π/2, √π 2n n!, and 1. The Gram matrix graph shows <Pn,Pm>/√(hnhm): ones on the diagonal and zeros elsewhere up to quadrature error.

Expansion and the error

The best weighted least-squares approximation with N terms is SN(x) = ∑k<N ck Pk(x) with ck = <f,Pk>/hk. Because the polynomials are orthogonal, the squared error is ||f - SN||² = ||f||² - ∑k<N ck² hk (Bessel's identity, with equality in the limit by Parseval). Smooth functions such as exp(t) have coefficients that fall faster than any power of k; a function with a kink (|t|) falls like k-2 and one with a jump like k-1; a polynomial of degree d is reproduced exactly once N > d.

Zeros

The zeros of PN are real, simple and lie inside the interval; zeros of consecutive degrees interlace. They are the nodes of Gauss quadrature, shown as green dots on the 2D page and as pegs on the 3D table.

Checks run in the page

1. Largest off-diagonal entry of the normalised Gram matrix (numerical integration). 2. The numerical norm of every Pn against the analytic hn. 3. Bessel's formula for the error against direct integration of (f - SN)²w for N = 1, 3, 6, 13. 4. The recurrence against an independent closed form (P5, T7(cos t) = cos 7t, H4 or L3).

Honest simplifications

Integrals use composite Simpson's rule (Legendre, Hermite, Laguerre) or the midpoint rule in the angle (Chebyshev) on a truncated range for the infinite intervals, so the checks pass to about 1e-6 rather than to rounding. The Hermite and Laguerre target functions are defined through t = (x - mid)/half-width, which is only a convenient scaling. Displayed polynomials are optionally divided by their maximum so that all degrees fit; the coefficients always refer to the unscaled polynomials.

Loading model...
Loading Blender model...
Basis functions up to the highlighted degree
Gram matrix of the first 13 polynomials (normalised)
Coefficient magnitudes |c_k| (orange = used terms)
Weighted L2 error against the number of terms
Made with 🟠 Blender · Three.js