Why this matters for simulation: Chebyshev polynomials are the basis of spectral methods for wall-bounded turbulence.
By the end of this lesson you can…
Write the generalized Fourier series of $f$ in any Sturm-Liouville eigenbasis, with the right weight in the coefficient formula.
Generate Legendre, Chebyshev, Hermite and Laguerre polynomials from their three-term recurrences, and explain why orthogonality forces such a recurrence.
Use $x = \cos\theta$ to turn a Chebyshev series into a cosine series, and say why a non-periodic function converges fast in Chebyshev but badly in a plain Fourier series.
Expand a function in $J_0(j_k r)$ on a disc, and read the drumhead frequency ratios and the pipe spin-down decay rates from the zeros of $J_0$.
Show that an $n$-point Gauss-Legendre rule is exact for degree $2n-1$, and use the Chebyshev points to avoid the Runge phenomenon.
8.5 Convergence & the Gibbs Phenomenon ended by promising to check what carries over from sines and cosines to other bases. This lesson does that check with four tools: orthogonal polynomials, Bessel functions, Gauss quadrature and interpolation at special points. They matter for simulation because every solver that stores a field as a handful of coefficients is making a choice of basis. Fourier suits a periodic box, which is the setting of Stam-style fluid solvers. A wind tunnel has walls, a pipe has a centerline, and a sphere has poles, and there the sines are the wrong functions.
▶ VideoOrthogonal polynomials from a recurrence, x = cos(theta) turning Chebyshev into cosines, the drumhead modes, and Gauss nodescaptions only
Transcript
Any Sturm-Liouville problem gives a basis, and the coefficient of f is the integral of f times the eigenfunction times the weight, divided by the same integral for the eigenfunction squared. Legendre has weight 1, Chebyshev one over root one minus x squared, Hermite e to the minus x squared, Laguerre e to the minus x. With the right weight, the largest off-diagonal Gram entry is below 10 to the minus 11. With the wrong weight it jumps to 0.614, 0.497, 0.828 and 0.926.
Why does each family have a three-term recurrence? Multiply P n by x and you get degree n plus 1. Its overlap with every lower-degree polynomial vanishes by orthogonality, so only three neighbours survive. Legendre: n plus 1 times P n plus 1 equals 2n plus 1 times x P n, minus n P n minus 1. At x equals 0.3 the loop gives P 2 equals minus 0.365, P 3 minus 0.3825, P 4 0.0729375, and P 5 0.34538625.
Now expand e to the x on minus 1 to 1. The Legendre coefficients are 1.17520, 1.10364, 0.35781, 0.07046. Chebyshev has a trick. Put x equal to cosine theta: T n becomes cosine n theta, so a Chebyshev series is a cosine series of f of cosine theta, and the ends of the interval are ordinary points. The maximum error at 5 terms is 1.07 times 10 to the minus 4 for Legendre and 4.79 times 10 to the minus 5 for Chebyshev. At 10 terms, 7.63 times 10 to the minus 11 and 2.60 times 10 to the minus 11. Period-2 Fourier is still at 1.19.
Repeat e to the x with period 2. At the seam it jumps from e back to 1 over e, so the series carries a Gibbs bump at the ends that never shrinks, and its rms error falls only like N to the minus a half, measured slope minus 0.49. The smoothness rule still holds for the polynomials. For absolute x, a corner, the slopes from 10 to 40 terms are minus 1.43 and minus 1.44, predicted minus 1.5. For sign of x, a jump, minus 0.48 and minus 0.49, predicted minus 0.5.
The Runge function has poles at plus and minus 0.2 i, so the Chebyshev error shrinks geometrically but slowly, by 7.3 per 10 terms. Interpolation is worse. Through equispaced points, the maximum error is 0.43269, 1.91566 and 59.82 at degrees 5, 10 and 20. Through the Chebyshev points, cosine of j pi over n, it is 0.63864, 0.13220 and 0.01774. They cluster at the walls, which is why spectral channel-flow solvers use them.
A round drum separates in polar coordinates. The radial problem has weight r, stays bounded at the centre, and a clamped rim needs J 0 to vanish. The zeros are 2.404826, 5.520078, 8.653728, 11.791534. Frequencies are proportional to them, so the ratios to the fundamental are 1, 2.2954, 3.5985 and 4.9033, not the whole numbers of a string. Modes with angular structure use zeros of J 1 and J 2: 3.8317 and 5.1356, ratios 1.5933 and 2.1355.
Expand the Poiseuille profile 1 minus r squared in Bessel functions. The coefficients are 1.10802, minus 0.13978, 0.04548, minus 0.02099. Switch off the pressure gradient and each mode simply decays, at rate j squared: 5.7832 for the first, 30.4713 for the second. At nu t over R squared equal to 0.2 the centerline speed is 0.3482. For a centimetre of water the slowest decay time is 17.3 seconds. And convergence follows the boundary: 1 minus r squared vanishes at the wall, slope minus 2.47. The constant 1 does not, and gets only minus 0.49.
n points normally integrate degree n minus 1 exactly. Choose the nodes too, as the zeros of P n, and you get degree 2n minus 1. For n equal to 3 the nodes are 0 and plus or minus 0.77459667, with weights 5 ninths, 8 ninths, 5 ninths. For e to the x, the errors at 2, 3, 5 and 10 points are 7.71 times 10 to the minus 3, 6.55 times 10 to the minus 5, 8.25 times 10 to the minus 10, and round-off. The trapezoid rule is stuck at second order: 0.736, 0.193, 4.88 times 10 to the minus 2, 9.66 times 10 to the minus 3.
A weight, an interval and a recurrence give a basis, and the wrong weight loses orthogonality. Putting x equal to cosine theta makes Chebyshev a cosine series with no seam: 2.60 times 10 to the minus 11 at 10 terms, against 1.19 for Fourier. Bessel zeros give the drum ratios and the pipe spin-down rates. Gauss nodes are exact through degree 2n minus 1, and Chebyshev points tame Runge. Next, the wave equation and vibrating strings, where the first of these bases goes to work on a physical problem.
Generalized Fourier series: nothing new but the weight
8.2 Eigenvalue Problems & Sturm–Liouville Theory proved that eigenfunctions yk of −(py′)′+qy=λwy are orthogonal with weight w: ∫yjykwdx=0 for j=k. If f=∑ckyk, multiply by yjw, integrate, and every term but one dies:
ck=∫yk2wdx∫fykwdx.
That is the Fourier coefficient formula with w inserted, and it is the same geometry as 1.1 Vectors, Linear Combinations & Span: ck is the projection of f on yk in the inner product ⟨f,g⟩=∫fgwdx. Completeness (every square-integrable f is a mean-square limit of such sums) is the theorem from the previous lesson’s callout, from memory. The Dirichlet and Gibbs story of 8.5 Convergence & the Gibbs Phenomenon was worked out for sines and cosines. For other bases, the sim below checks the convergence-rate part; the claim that a Gibbs overshoot appears at a jump in every such basis is from memory, and I did not measure it here.
Legendre polynomials: weight 1 on [−1,1]
5.8 Series Solutions derived them: the series solution of (1−x2)y′′−2xy′+n(n+1)y=0 stops when n is an integer, giving Pn with Pn(1)=1. In Sturm-Liouville form this is −((1−x2)y′)′=λy with λ=n(n+1), p=1−x2 and w=1. Since p vanishes at ±1 the problem is singular, like Bessel’s, and the boundary condition is “stay bounded”, which kills the log-divergent second solution. So ∫−11PjPkdx=0 for j=k, and (from memory) ∫−11Pn2dx=2n+12.
The three-term recurrence is forced by orthogonality. The function xPn is a polynomial of degree n+1, so xPn=∑k≤n+1dkPk. For k<n−1, the coefficient is ∫xPnPkdx=∫Pn(xPk)dx=0, because xPk has degree k+1<n and Pn is orthogonal to every lower-degree polynomial. Only Pn−1,Pn,Pn+1 survive, and parity removes Pn. Normalizing with Pn(1)=1 gives
(n+1)Pn+1(x)=(2n+1)xPn(x)−nPn−1(x).
By hand at x=0.3: P2=21(3⋅0.09−1)=−0.365 and P3=21(5⋅0.027−0.9)=−0.3825. Then 4P4=7(0.3)(−0.3825)−3(−0.365)=0.29175 gives P4=0.0729375, and 5P5=9(0.3)(0.0729375)+4(0.3825) gives P5(0.3)=0.34538625. The sim’s recurrence returns 0.34538625. Codes evaluate Pn this way: a loop with no powers, stable where the monomial form ∑akxk loses digits to cancellation (5.8 Series Solutions).
◆ InteractiveFour panels: polynomial families, expansions in three bases, Fourier-Bessel on a disc, Gauss nodes
Loading simulation…
What to try (polynomial panel). Switch between the four families and slide the degree: Pn and Tn wiggle between −1 and 1 with n zeros, as the oscillation theorem of the previous lesson predicts. The right panel is the Gram matrix ∣Gjk∣/GjjGkk of degrees 0 to 7, with Gjk=∫pjpkwdx. With the correct weight the largest off-diagonal entry is below 10−11 for all four families (the sim’s Simpson quadrature error; an independent adaptive quadrature gives below 2×10−13): zero up to quadrature error. Now tick wrong weight: it rises to 0.614, 0.497, 0.828 and 0.926.
A worked expansion
Expand f=ex in Legendre polynomials. The projection formula, with ∫Pn2=2n+12, gives cn=22n+1∫−11exPndx. For n=0 it is 21(e−e−1)=sinh1=1.17520. For n=1, integrate by parts:
The sim finds c0,c1,c2,c3=1.17520,1.10364,0.35781,0.07046, so c2=25(e−7e−1)=0.35781 agrees too.
Chebyshev polynomials: it is a cosine series in disguise
Put x=cosθ with 0≤θ≤π. The Chebyshev polynomial is Tn(x)=cos(narccosx), i.e. Tn(cosθ)=cosnθ. It is a polynomial: the identity cos(n+1)θ+cos(n−1)θ=2cosθcosnθ reads
Tn+1=2xTn−Tn−1,T0=1,T1=x,
so T2=2x2−1, T3=4x3−3x, and at x=0.3 the recurrence gives T5=0.99888, equal to cos(5arccos0.3)=0.99888.
Orthogonality is the cosine orthogonality of 8.3 Fourier Series after the substitution dx=−sinθdθ:
That is where the strange weight w=1/1−x2 comes from: it is exactly the Jacobian 1/sinθ. (Without the weight, ∫T0T2dx=∫(2x2−1)dx=−32 is not zero; with the weight 1 the sim’s wrong-weight Gram entry for degrees 0 and 2 is 0.4880=2⋅14/152/3.)
Consequence: a Chebyshev series of f(x) is the cosine series of g(θ)=f(cosθ). The function g is automatically even and 2π-periodic, and it is smooth wherever f is smooth, including at x=±1 (the ends become θ=0,π, ordinary points of a cosine series, and the even extension of 8.4 Even & Odd Extensions: Sine and Cosine Series is built in). So the whole of 8.5 Convergence & the Gibbs Phenomenon applies to g, and the coefficients are computed by the FFT.
The sim’s expansion panel makes the contrast. For f=ex on [−1,1], with max error of the N-term sum:
basis
N=5
N=10
N=20
Legendre
1.07×10−4
7.63×10−11
round-off, below 10−13
Chebyshev
4.79×10−5
2.60×10−11
round-off, below 10−13
Fourier, period 2
1.21
1.19
1.17
(The Chebyshev and Legendre coefficients reach round-off, about 10−15, by N=40; it is a floor, not a trend.) The Fourier series of the periodic extension of ex jumps from e back to e−1 at the seam, so it has a Gibbs bump at the ends that never shrinks, and its rms error falls only like N−1/2 (measured slope −0.49). Chebyshev and Legendre see no seam. The Chebyshev coefficients 2Ik(1) (modified Bessel functions, from memory) are 1.26607, 1.13032, 0.27150, 0.04434 for k=0,…,3 in the sim, with c0 the unhalved average. Chebyshev beats Legendre slightly in maximum error (a Chebyshev partial sum is close to the best uniform approximation by degree-N polynomials, from memory) and, crucially, has the FFT.
For a function analytic near [−1,1] the error falls geometrically, like ρ−N, where ρ comes from the nearest singularity in the complex plane (the Bernstein ellipse; from memory). The Runge function 1/(1+25x2) has poles at ±0.2i, giving ρ=0.2+1.04=1.2198, so the rms error should drop by ρ10≈7.3 per 10 terms. The sim’s Legendre rms errors at N=10 and N=20 are 3.95×10−2 and 5.42×10−3, a ratio of 7.3. Geometric, but with a slow rate: a pole close to the interval is expensive. Here the plain Fourier series is better at N=20 (6.6×10−5 rms against 5.6×10−3 for Chebyshev), because the Runge function happens to be nearly periodic; the geometric rate wins only at larger N.
Hermite and Laguerre, briefly
Two more families have weights on unbounded intervals. HermiteHn (physicists’ version) has weight e−x2 on the whole line and Hn+1=2xHn−2nHn−1; ∫Hn2e−x2dx=π2nn! (from memory), and the sim gives 1.772454,3.544908,14.179631,85.077785,680.622279 for n=0,…,4. LaguerreLn has weight e−x on [0,∞), (n+1)Ln+1=(2n+1−x)Ln−nLn−1, and unit norm (all five sim values are 1.000000). At x=0.3, H4=7.8096 and L4=0.0523375 in the sim; the first is checked by hand: H2=4x2−2=−1.64, H3=8x3−12x=−3.384, H4=2x(−3.384)−6(−1.64)=7.8096. Hermite functions are quantum-oscillator modes and Hermite moments expand velocity distributions in lattice Boltzmann methods (from memory). The pattern is the same: a weight, an interval, a recurrence.
Bessel functions on a disc
A round drum or a round pipe separates in polar coordinates. The radial equation (5.8 Series Solutions) is Bessel’s equation of order zero in the form −(ry′)′=λry on 0<r<1: Sturm-Liouville with p=r and weight w=r (the area element), singular at r=0, with bounded solution J0(λr). Imposing y(1)=0 (a clamped rim, or a no-slip wall) needs J0(λ)=0, so λk=jk, the k-th zero of J0. The sim computes Jm(x)=π1∫0πcos(mt−xsint)dt (an integral form, from memory) with the trapezoid rule and gets jk=2.404826,5.520078,8.653728,11.791534,14.930918,18.071064, the zeros quoted in 5.8 Series Solutions.
The drum. The frequency of each axisymmetric mode is proportional to jk, so the ratios to the fundamental are 1,2.2954,3.5985,4.9033: not the whole numbers of a string, which is why a drum has no clear pitch. Modes with an angular dependence cosmφ use zeros of Jm: the first zeros of J1 and J2 are 3.8317 and 5.1356, ratios 1.5933 and 2.1355 to the fundamental (angular structure from memory).
The Fourier-Bessel series. Orthogonality ∫01rJ0(jjr)J0(jkr)dr=0 for j=k and, from memory, ∫01rJ0(jkr)2dr=21J1(jk)2 give
Convergence follows the smoothness rule, with a catch. For f=1−r2 (which vanishes at the wall, like every J0(jkr)) the weighted rms error of the N-mode sum, averaged over the disc, is 4.95×10−2,1.79×10−3,6.24×10−5,1.12×10−5 at N=1,5,20,40: a slope of −2.47 over N=10 to 40. Since J1(j)∼2/(πj), ck∼jk−5/2, and summing the tail of ck2⋅21J12 predicts −2.5. For f=1, which does not vanish at the wall, every partial sum is 0 at r=1, so the wall value is wrong forever; the rms errors are 0.555,0.277,0.141,0.100 and the slope is −0.494, the square wave’s rate. The lesson of 8.4 Even & Odd Extensions: Sine and Cosine Series returns: an expansion converges fast only if f already satisfies the boundary conditions of the basis.
Gauss quadrature: orthogonality pays for numerical integration
The payoff for the numerical-methods mind. Integrating f over [−1,1] with n points normally gets degree n−1 exactly: interpolate and integrate. Gauss-Legendre chooses the n nodes freely as well as the weights, which gives 2n unknowns and an exactness of degree 2n−1. The nodes are the zeros of Pn. Proof: divide a polynomial f of degree ≤2n−1 by Pn, f=qPn+r with degq,degr≤n−1. Then ∫qPndx=0 by orthogonality, so ∫f=∫r. At the nodes Pn=0, so f(xi)=r(xi), and the rule with interpolatory weights integrates r exactly.
For n=3 the zeros of P3=21(5x3−3x) are 0,±3/5=±0.77459667, with weights 95,98,95. Check on ∫−11x4dx=52: the nodes have x4=0.36 and 0, so the rule gives 2⋅95⋅0.36=0.4. A degree-5 polynomial is the highest exact one.
Why spectral methods use Chebyshev points
Interpolating through n+1equispaced points is notoriously unstable. For the Runge function the maximum error of the degree-n interpolant is 0.43269, 1.91566 and 59.82 at n=5,10,20: it grows, with huge swings at the ends. Interpolating at the Chebyshev pointsxj=cos(jπ/n) gives 0.63864, 0.13220 and 0.01774: it converges. (The sim’s Gauss-nodes panel draws both.) The Chebyshev points are the θ-uniform grid mapped by x=cosθ, so they cluster near the ends, spacing ∼1/n2 there. A differentiation matrix on these points is the core of Chebyshev spectral collocation (10.12 Spectral Methods & the FFT).
Computing it
🐍 PythonLab: Chebyshev coefficients of exp(x) from the cosine series, and the three-term recurrence
⌘/Ctrl + Enter
Now implement the recurrence and Gauss-Legendre nodes yourself.
🧪 Coding exerciseExercise: Legendre recurrence and an n-point Gauss-Legendre rule✓ passed
⌘/Ctrl + Enter
💡 Evaluate P_n and P_{n-1} with your recurrence inside the Newton loop; 20 iterations are plenty. Recompute P_n' after the loop for the weights.
Concept checks
✅ Concept check
Which formula gives the coefficients of $f = \sum c_nT_n$ in Chebyshev polynomials?
Why: Orthogonality is with respect to the weight; the weight is where the substitution's $\\sin\\theta$ went.
✅ Concept check
Why does the period-2 Fourier series of $e^x$ on $[-1, 1]$ stay at max error about $1.2$ while its Chebyshev series reaches $10^{-10}$ with ten terms?
Why: A series converges quickly only if the function it implicitly builds is smooth: the seam is what hurt Fourier.
✅ Concept check
What is the highest degree of polynomial that a 4-point Gauss-Legendre rule integrates exactly?
Why: $2n - 1 = 7$: $n$ free nodes plus $n$ free weights give $2n$ conditions.
✅ Concept check
The first axisymmetric drum mode has frequency $f_1$. The second axisymmetric mode has frequency about
Why: Frequency is proportional to $j_k = \\sqrt{\\lambda_k}$, giving ratios $1, 2.2954, 3.5985, 4.9033$.
Problems
✏️ Pen & paperExpanding $x^2$ and $x^3$●○○
Write x2 and x3 as combinations of Legendre polynomials, using P2=21(3x2−1) and P3=21(5x3−3x).
Show worked solution
x2: from P2, x2=31(2P2+1)=32P2+31P0. Check at x=1: 32+31=1. x3: from P3, x3=51(2P3+3x)=52P3+53P1; at x=1 this is 1. A polynomial of degree m needs only P0,…,Pm, and the same coefficients come from cn=22n+1∫fPndx: for instance c2=25∫x2P2dx=45(56−32)=32.
✏️ Pen & paperChebyshev by recurrence and by orthogonality●●○
(a) Use Tn+1=2xTn−Tn−1 to find T4 and show T4(cosθ)=cos4θ at θ=π/3. (b) Show ∫−11T1T3(1−x2)−1/2dx=0 and compute ∫−11T32(1−x2)−1/2dx.
Show worked solution
(a) T2=2x2−1, T3=2x(2x2−1)−x=4x3−3x, T4=2x(4x3−3x)−(2x2−1)=8x4−8x2+1. At θ=π/3, x=21: T4=21−2+1=−21 and cos(4π/3)=−21. (b) With x=cosθ the weight cancels dx: the integral is ∫0πcosθcos3θdθ=21∫0π(cos4θ+cos2θ)dθ=0, and ∫0πcos23θdθ=2π.
✏️ Pen & paperThe two-point Gauss rule●●○
Find the nodes ±a and equal weights w for a two-point rule on [−1,1] exact for 1,x,x2,x3. Apply it to ∫−11exdx and compare with the exact 2.3504024.
Show worked solution
Exactness for 1 gives 2w=2, so w=1. For x2: 2a2=32, so a=1/3=0.57735, the zeros of P2=21(3x2−1). Odd powers vanish by symmetry, so x and x3 are exact too. The rule gives e0.57735+e−0.57735=2cosh(0.57735)=2.34270. The error is 2.3504024−2.3427=7.7×10−3, the sim’s n=2 value 7.71×10−3.
✏️ Pen & paperHow long does a pipe flow remember its profile?●○○
A pipe of radius R=2 cm carries oil with ν=5×10−5 m2/s. After the pressure gradient is switched off, how long until the first-mode part of the centerline speed has dropped by a factor e?
Show worked solution
The first mode decays as exp(−j12νt/R2) with j12=5.7832, so the time is t=R2/(j12ν). With R2=4×10−4 m2: t=4×10−4/(5.7832×5×10−5)=1.38 s. Higher modes decay faster (30.47 for the second), so after a few such times only the first mode is left.
Key Takeaways
Any Sturm-Liouville eigenbasis gives a generalized Fourier series with ck=∫fykw/∫yk2w; the weight must be the problem’s weight or the basis is not orthogonal (wrong-weight Gram entries up to 0.93).
Legendre (w=1), Chebyshev (w=1/1−x2), Hermite (e−x2) and Laguerre (e−x) polynomials are generated by three-term recurrences, which orthogonality forces; P5(0.3)=0.34538625.
x=cosθ makes a Chebyshev series a cosine series with the FFT, and removes the endpoint seam: for ex the Chebyshev max error is 2.6×10−11 at N=10 against 1.19 for period-2 Fourier.
The smoothness rule survives: rms slopes about −1.4 for a corner and −0.5 for a jump, geometric convergence for analytic functions at a rate set by the nearest complex singularity (Runge: ρ=1.2198).
Fourier-Bessel series on a disc use the weight r and the zeros of J0 (2.404826,5.520078,…); they give drum frequency ratios 1,2.2954,3.5985 and pipe spin-down rates jk2ν/R2.
Convergence is fast only if f satisfies the basis’s boundary conditions: 1−r2 gives slope −2.47, f=1 gives −0.49.
An n-point Gauss-Legendre rule is exact through degree 2n−1 because its nodes are zeros of Pn; for ex five points give error 8.3×10−10 against 4.9×10−2 for the trapezoid rule.
Chebyshev points tame the Runge phenomenon (interpolation error 0.132 at n=10 against 1.92 equispaced), which is why wall-bounded spectral solvers use them.
What comes next
We now have the toolbox: eigenfunction bases for every geometry we will meet. The next lesson, 9.4 The Wave Equation & Vibrating Strings, puts the first basis to work on a physical problem: a vibrating string. I expect the string lesson to bring the standing-wave picture; the drumhead modes of this lesson need the wave equation in two space dimensions, which comes later, so treat the Bessel frequency ratios here as a preview that the PDE lessons still have to confirm.
Finished this lesson?
Mark it complete to track your progress (saved in this browser). Reading every section does this for you.