Flow Lab

Syllabus / Module 8: Boundary Value Problems & Fourier Series

Lesson 8.6

Orthogonal Polynomials & Special Functions

Legendre polynomials, Bessel functions and generalized Fourier series in other orthogonal bases.

Written byClaude Sonnet

🌊
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.
On this page
·
  1. Generalized Fourier series: nothing new but the weight
  2. Legendre polynomials: weight 1 on [−1,1][-1, 1][−1,1]
  3. A worked expansion
  4. Chebyshev polynomials: it is a cosine series in disguise
  5. Hermite and Laguerre, briefly
  6. Bessel functions on a disc
  7. Gauss quadrature: orthogonality pays for numerical integration
  8. Why spectral methods use Chebyshev points
  9. Computing it
  10. Concept checks
  11. Problems
  12. Key Takeaways
  13. What comes next

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.

▶ Video Orthogonal polynomials from a recurrence, x = cos(theta) turning Chebyshev into cosines, the drumhead modes, and Gauss nodescaptions only
Transcript
  1. 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.
  2. 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.
  3. 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.
  4. 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.
  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.
  6. 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.
  7. 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.
  8. 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.
  9. 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 yky_k of −(py′)′+qy=λwy-(py')' + qy = \lambda w y are orthogonal with weight ww: ∫yjyk w dx=0\int y_jy_k\,w\,dx = 0 for j≠kj \ne k. If f=∑ckykf = \sum c_ky_k, multiply by yjwy_jw, integrate, and every term but one dies:

ck=∫f yk w dx∫yk2 w dx.c_k = \frac{\int f\,y_k\,w\,dx}{\int y_k^2\,w\,dx}.

That is the Fourier coefficient formula with ww inserted, and it is the same geometry as 1.1 Vectors, Linear Combinations & Span: ckc_k is the projection of ff on yky_k in the inner product ⟨f,g⟩=∫fg w dx\langle f, g\rangle = \int fg\,w\,dx. Completeness (every square-integrable ff 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][-1, 1]

5.8 Series Solutions derived them: the series solution of (1−x2)y′′−2xy′+n(n+1)y=0(1-x^2)y'' - 2xy' + n(n+1)y = 0 stops when nn is an integer, giving PnP_n with Pn(1)=1P_n(1) = 1. In Sturm-Liouville form this is −((1−x2)y′)′=λy-\bigl((1-x^2)y'\bigr)' = \lambda y with λ=n(n+1)\lambda = n(n+1), p=1−x2p = 1 - x^2 and w=1w = 1. Since pp vanishes at ±1\pm1 the problem is singular, like Bessel’s, and the boundary condition is “stay bounded”, which kills the log-divergent second solution. So ∫−11PjPk dx=0\int_{-1}^1P_jP_k\,dx = 0 for j≠kj \ne k, and (from memory) ∫−11Pn2 dx=22n+1\int_{-1}^1P_n^2\,dx = \tfrac{2}{2n+1}.

The three-term recurrence is forced by orthogonality. The function xPnxP_n is a polynomial of degree n+1n+1, so xPn=∑k≤n+1dkPkxP_n = \sum_{k\le n+1}d_kP_k. For k<n−1k \lt n - 1, the coefficient is ∫xPnPk dx=∫Pn (xPk) dx=0\int xP_nP_k\,dx = \int P_n\,(xP_k)\,dx = 0, because xPkxP_k has degree k+1<nk+1 \lt n and PnP_n is orthogonal to every lower-degree polynomial. Only Pn−1,Pn,Pn+1P_{n-1}, P_n, P_{n+1} survive, and parity removes PnP_n. Normalizing with Pn(1)=1P_n(1) = 1 gives

(n+1)Pn+1(x)=(2n+1) x Pn(x)−n Pn−1(x).(n+1)P_{n+1}(x) = (2n+1)\,x\,P_n(x) - n\,P_{n-1}(x).

By hand at x=0.3x = 0.3: P2=12(3⋅0.09−1)=−0.365P_2 = \tfrac12(3\cdot0.09 - 1) = -0.365 and P3=12(5⋅0.027−0.9)=−0.3825P_3 = \tfrac12(5\cdot0.027 - 0.9) = -0.3825. Then 4P4=7(0.3)(−0.3825)−3(−0.365)=0.291754P_4 = 7(0.3)(-0.3825) - 3(-0.365) = 0.29175 gives P4=0.0729375P_4 = 0.0729375, and 5P5=9(0.3)(0.0729375)+4(0.3825)5P_5 = 9(0.3)(0.0729375) + 4(0.3825) gives P5(0.3)=0.34538625P_5(0.3) = 0.34538625. The sim’s recurrence returns 0.345386250.34538625. Codes evaluate PnP_n this way: a loop with no powers, stable where the monomial form ∑akxk\sum a_kx^k loses digits to cancellation (5.8 Series Solutions).

◆ Interactive Four 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: PnP_n and TnT_n wiggle between −1-1 and 11 with nn zeros, as the oscillation theorem of the previous lesson predicts. The right panel is the Gram matrix ∣Gjk∣/GjjGkk|G_{jk}|/\sqrt{G_{jj}G_{kk}} of degrees 00 to 77, with Gjk=∫pjpk w dxG_{jk} = \int p_jp_k\,w\,dx. With the correct weight the largest off-diagonal entry is below 10−1110^{-11} for all four families (the sim’s Simpson quadrature error; an independent adaptive quadrature gives below 2×10−132\times10^{-13}): zero up to quadrature error. Now tick wrong weight: it rises to 0.6140.614, 0.4970.497, 0.8280.828 and 0.9260.926.

A worked expansion

Expand f=exf = e^x in Legendre polynomials. The projection formula, with ∫Pn2=22n+1\int P_n^2 = \tfrac2{2n+1}, gives cn=2n+12∫−11exPn dxc_n = \tfrac{2n+1}{2}\int_{-1}^1e^xP_n\,dx. For n=0n = 0 it is 12(e−e−1)=sinh⁡1=1.17520\tfrac12(e - e^{-1}) = \sinh 1 = 1.17520. For n=1n = 1, integrate by parts:

c1=32∫−11xex dx=32[(x−1)ex]−11=32⋅2e−1=3e=1.10364.c_1 = \frac32\int_{-1}^1xe^x\,dx = \frac32\Bigl[(x-1)e^x\Bigr]_{-1}^{1} = \frac32\cdot2e^{-1} = \frac3e = 1.10364 .

The sim finds c0,c1,c2,c3=1.17520, 1.10364, 0.35781, 0.07046c_0, c_1, c_2, c_3 = 1.17520,\ 1.10364,\ 0.35781,\ 0.07046, so c2=52(e−7e−1)=0.35781c_2 = \tfrac52(e - 7e^{-1}) = 0.35781 agrees too.

Chebyshev polynomials: it is a cosine series in disguise

Put x=cos⁡θx = \cos\theta with 0≤θ≤π0 \le \theta \le \pi. The Chebyshev polynomial is Tn(x)=cos⁡(narccos⁡x)T_n(x) = \cos(n\arccos x), i.e. Tn(cos⁡θ)=cos⁡nθT_n(\cos\theta) = \cos n\theta. It is a polynomial: the identity cos⁡(n+1)θ+cos⁡(n−1)θ=2cos⁡θcos⁡nθ\cos(n+1)\theta + \cos(n-1)\theta = 2\cos\theta\cos n\theta reads

Tn+1=2xTn−Tn−1,T0=1, T1=x,T_{n+1} = 2xT_n - T_{n-1},\qquad T_0 = 1,\ T_1 = x,

so T2=2x2−1T_2 = 2x^2 - 1, T3=4x3−3xT_3 = 4x^3 - 3x, and at x=0.3x = 0.3 the recurrence gives T5=0.99888T_5 = 0.99888, equal to cos⁡(5arccos⁡0.3)=0.99888\cos(5\arccos0.3) = 0.99888.

Orthogonality is the cosine orthogonality of 8.3 Fourier Series after the substitution dx=−sin⁡θ dθdx = -\sin\theta\,d\theta:

∫−11TjTk1−x2 dx=∫0πcos⁡jθcos⁡kθ dθ={0j≠kπ/2j=k≥1πj=k=0.\int_{-1}^{1}\frac{T_jT_k}{\sqrt{1 - x^2}}\,dx = \int_0^\pi\cos j\theta\cos k\theta\,d\theta = \begin{cases}0 & j \ne k\\ \pi/2 & j = k \ge 1\\ \pi & j = k = 0.\end{cases}

That is where the strange weight w=1/1−x2w = 1/\sqrt{1-x^2} comes from: it is exactly the Jacobian 1/sin⁡θ1/\sin\theta. (Without the weight, ∫T0T2 dx=∫(2x2−1) dx=−23\int T_0T_2\,dx = \int(2x^2-1)\,dx = -\tfrac23 is not zero; with the weight 11 the sim’s wrong-weight Gram entry for degrees 00 and 22 is 0.4880=2/32⋅14/150.4880 = \tfrac{2/3}{\sqrt{2\cdot14/15}}.)

Consequence: a Chebyshev series of f(x)f(x) is the cosine series of g(θ)=f(cos⁡θ)g(\theta) = f(\cos\theta). The function gg is automatically even and 2π2\pi-periodic, and it is smooth wherever ff is smooth, including at x=±1x = \pm1 (the ends become θ=0,π\theta = 0, \pi, 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 gg, and the coefficients are computed by the FFT.

The sim’s expansion panel makes the contrast. For f=exf = e^x on [−1,1][-1, 1], with max error of the NN-term sum:

basisN=5N = 5N=10N = 10N=20N = 20
Legendre1.07×10−41.07\times10^{-4}7.63×10−117.63\times10^{-11}round-off, below 10−1310^{-13}
Chebyshev4.79×10−54.79\times10^{-5}2.60×10−112.60\times10^{-11}round-off, below 10−1310^{-13}
Fourier, period 21.211.211.191.191.171.17

(The Chebyshev and Legendre coefficients reach round-off, about 10−1510^{-15}, by N=40N = 40; it is a floor, not a trend.) The Fourier series of the periodic extension of exe^x jumps from ee back to e−1e^{-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/2N^{-1/2} (measured slope −0.49-0.49). Chebyshev and Legendre see no seam. The Chebyshev coefficients 2Ik(1)2I_k(1) (modified Bessel functions, from memory) are 1.266071.26607, 1.130321.13032, 0.271500.27150, 0.044340.04434 for k=0,…,3k = 0, \dots, 3 in the sim, with c0c_0 the unhalved average. Chebyshev beats Legendre slightly in maximum error (a Chebyshev partial sum is close to the best uniform approximation by degree-NN polynomials, from memory) and, crucially, has the FFT.

For a function analytic near [−1,1][-1,1] the error falls geometrically, like ρ−N\rho^{-N}, where ρ\rho comes from the nearest singularity in the complex plane (the Bernstein ellipse; from memory). The Runge function 1/(1+25x2)1/(1+25x^2) has poles at ±0.2i\pm0.2i, giving ρ=0.2+1.04=1.2198\rho = 0.2 + \sqrt{1.04} = 1.2198, so the rms error should drop by ρ10≈7.3\rho^{10} \approx 7.3 per 1010 terms. The sim’s Legendre rms errors at N=10N = 10 and N=20N = 20 are 3.95×10−23.95\times10^{-2} and 5.42×10−35.42\times10^{-3}, a ratio of 7.37.3. Geometric, but with a slow rate: a pole close to the interval is expensive. Here the plain Fourier series is better at N=20N = 20 (6.6×10−56.6\times10^{-5} rms against 5.6×10−35.6\times10^{-3} for Chebyshev), because the Runge function happens to be nearly periodic; the geometric rate wins only at larger NN.

Hermite and Laguerre, briefly

Two more families have weights on unbounded intervals. Hermite HnH_n (physicists’ version) has weight e−x2e^{-x^2} on the whole line and Hn+1=2xHn−2nHn−1H_{n+1} = 2xH_n - 2nH_{n-1}; ∫Hn2e−x2dx=π 2nn!\int H_n^2e^{-x^2}dx = \sqrt\pi\,2^nn! (from memory), and the sim gives 1.772454, 3.544908, 14.179631, 85.077785, 680.6222791.772454,\ 3.544908,\ 14.179631,\ 85.077785,\ 680.622279 for n=0,…,4n = 0, \dots, 4. Laguerre LnL_n has weight e−xe^{-x} on [0,∞)[0, \infty), (n+1)Ln+1=(2n+1−x)Ln−nLn−1(n+1)L_{n+1} = (2n+1-x)L_n - nL_{n-1}, and unit norm (all five sim values are 1.0000001.000000). At x=0.3x = 0.3, H4=7.8096H_4 = 7.8096 and L4=0.0523375L_4 = 0.0523375 in the sim; the first is checked by hand: H2=4x2−2=−1.64H_2 = 4x^2 - 2 = -1.64, H3=8x3−12x=−3.384H_3 = 8x^3 - 12x = -3.384, H4=2x(−3.384)−6(−1.64)=7.8096H_4 = 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′)′=λ r y-(ry')' = \lambda\,r\,y on 0<r<10 \lt r \lt 1: Sturm-Liouville with p=rp = r and weight w=rw = r (the area element), singular at r=0r = 0, with bounded solution J0(λ r)J_0(\sqrt\lambda\,r). Imposing y(1)=0y(1) = 0 (a clamped rim, or a no-slip wall) needs J0(λ)=0J_0(\sqrt\lambda) = 0, so λk=jk\sqrt{\lambda_k} = j_k, the kk-th zero of J0J_0. The sim computes Jm(x)=1π∫0πcos⁡(mt−xsin⁡t) dtJ_m(x) = \tfrac1\pi\int_0^\pi\cos(m t - x\sin t)\,dt (an integral form, from memory) with the trapezoid rule and gets jk=2.404826, 5.520078, 8.653728, 11.791534, 14.930918, 18.071064j_k = 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 jkj_k, so the ratios to the fundamental are 1, 2.2954, 3.5985, 4.90331,\ 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 cos⁡mφ\cos m\varphi use zeros of JmJ_m: the first zeros of J1J_1 and J2J_2 are 3.83173.8317 and 5.13565.1356, ratios 1.59331.5933 and 2.13552.1355 to the fundamental (angular structure from memory).

The Fourier-Bessel series. Orthogonality ∫01rJ0(jjr)J0(jkr) dr=0\int_0^1rJ_0(j_jr)J_0(j_kr)\,dr = 0 for j≠kj \ne k and, from memory, ∫01rJ0(jkr)2dr=12J1(jk)2\int_0^1 rJ_0(j_kr)^2dr = \tfrac12J_1(j_k)^2 give

f(r)=∑kckJ0(jkr),ck=∫01r f(r) J0(jkr) dr12J1(jk)2.f(r) = \sum_k c_kJ_0(j_kr),\qquad c_k = \frac{\int_0^1 r\,f(r)\,J_0(j_kr)\,dr}{\tfrac12J_1(j_k)^2}.

Convergence follows the smoothness rule, with a catch. For f=1−r2f = 1 - r^2 (which vanishes at the wall, like every J0(jkr)J_0(j_kr)) the weighted rms error of the NN-mode sum, averaged over the disc, is 4.95×10−2, 1.79×10−3, 6.24×10−5, 1.12×10−54.95\times10^{-2},\ 1.79\times10^{-3},\ 6.24\times10^{-5},\ 1.12\times10^{-5} at N=1,5,20,40N = 1, 5, 20, 40: a slope of −2.47-2.47 over N=10N = 10 to 4040. Since J1(j)∼2/(πj)J_1(j)\sim\sqrt{2/(\pi j)}, ck∼jk−5/2c_k \sim j_k^{-5/2}, and summing the tail of ck2⋅12J12c_k^2\cdot\tfrac12J_1^2 predicts −2.5-2.5. For f=1f = 1, which does not vanish at the wall, every partial sum is 00 at r=1r = 1, so the wall value is wrong forever; the rms errors are 0.555, 0.277, 0.141, 0.1000.555,\ 0.277,\ 0.141,\ 0.100 and the slope is −0.494-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 ff already satisfies the boundary conditions of the basis.

Gauss quadrature: orthogonality pays for numerical integration

The payoff for the numerical-methods mind. Integrating ff over [−1,1][-1, 1] with nn points normally gets degree n−1n - 1 exactly: interpolate and integrate. Gauss-Legendre chooses the nn nodes freely as well as the weights, which gives 2n2n unknowns and an exactness of degree 2n−12n - 1. The nodes are the zeros of PnP_n. Proof: divide a polynomial ff of degree ≤2n−1\le 2n - 1 by PnP_n, f=qPn+rf = qP_n + r with deg⁡q,deg⁡r≤n−1\deg q, \deg r \le n-1. Then ∫qPn dx=0\int qP_n\,dx = 0 by orthogonality, so ∫f=∫r\int f = \int r. At the nodes Pn=0P_n = 0, so f(xi)=r(xi)f(x_i) = r(x_i), and the rule with interpolatory weights integrates rr exactly.

For n=3n = 3 the zeros of P3=12(5x3−3x)P_3 = \tfrac12(5x^3 - 3x) are 0,±3/5=±0.774596670, \pm\sqrt{3/5} = \pm0.77459667, with weights 59,89,59\tfrac59, \tfrac89, \tfrac59. Check on ∫−11x4dx=25\int_{-1}^1x^4dx = \tfrac25: the nodes have x4=0.36x^4 = 0.36 and 00, so the rule gives 2⋅59⋅0.36=0.42\cdot\tfrac59\cdot0.36 = 0.4. A degree-55 polynomial is the highest exact one.

Why spectral methods use Chebyshev points

Interpolating through n+1n + 1 equispaced points is notoriously unstable. For the Runge function the maximum error of the degree-nn interpolant is 0.432690.43269, 1.915661.91566 and 59.8259.82 at n=5,10,20n = 5, 10, 20: it grows, with huge swings at the ends. Interpolating at the Chebyshev points xj=cos⁡(jπ/n)x_j = \cos(j\pi/n) gives 0.638640.63864, 0.132200.13220 and 0.017740.01774: it converges. (The sim’s Gauss-nodes panel draws both.) The Chebyshev points are the θ\theta-uniform grid mapped by x=cos⁡θx = \cos\theta, so they cluster near the ends, spacing ∼1/n2\sim 1/n^2 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
⌘/Ctrl + Enter

Concept checks

✅ Concept check

Which formula gives the coefficients of $f = \sum c_nT_n$ in Chebyshev polynomials?

✅ 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?

✅ Concept check

What is the highest degree of polynomial that a 4-point Gauss-Legendre rule integrates exactly?

✅ Concept check

The first axisymmetric drum mode has frequency $f_1$. The second axisymmetric mode has frequency about

Problems

✏️ Pen & paperExpanding $x^2$ and $x^3$●○○

Write x2x^2 and x3x^3 as combinations of Legendre polynomials, using P2=12(3x2−1)P_2 = \tfrac12(3x^2-1) and P3=12(5x3−3x)P_3 = \tfrac12(5x^3-3x).

Show worked solution

x2x^2: from P2P_2, x2=13(2P2+1)=23P2+13P0x^2 = \tfrac13(2P_2 + 1) = \tfrac23P_2 + \tfrac13P_0. Check at x=1x = 1: 23+13=1\tfrac23 + \tfrac13 = 1. x3x^3: from P3P_3, x3=15(2P3+3x)=25P3+35P1x^3 = \tfrac15(2P_3 + 3x) = \tfrac25P_3 + \tfrac35P_1; at x=1x = 1 this is 11. A polynomial of degree mm needs only P0,…,PmP_0, \dots, P_m, and the same coefficients come from cn=2n+12∫fPn dxc_n = \tfrac{2n+1}2\int fP_n\,dx: for instance c2=52∫x2P2 dx=54(65−23)=23c_2 = \tfrac52\int x^2P_2\,dx = \tfrac54\bigl(\tfrac65 - \tfrac23\bigr)= \tfrac23.

✏️ Pen & paperChebyshev by recurrence and by orthogonality●●○

(a) Use Tn+1=2xTn−Tn−1T_{n+1} = 2xT_n - T_{n-1} to find T4T_4 and show T4(cos⁡θ)=cos⁡4θT_4(\cos\theta) = \cos4\theta at θ=π/3\theta = \pi/3. (b) Show ∫−11T1T3 (1−x2)−1/2dx=0\int_{-1}^1T_1T_3\,(1-x^2)^{-1/2}dx = 0 and compute ∫−11T32(1−x2)−1/2dx\int_{-1}^1T_3^2(1-x^2)^{-1/2}dx.

Show worked solution

(a) T2=2x2−1T_2 = 2x^2 - 1, T3=2x(2x2−1)−x=4x3−3xT_3 = 2x(2x^2-1) - x = 4x^3 - 3x, T4=2x(4x3−3x)−(2x2−1)=8x4−8x2+1T_4 = 2x(4x^3 - 3x) - (2x^2 - 1) = 8x^4 - 8x^2 + 1. At θ=π/3\theta = \pi/3, x=12x = \tfrac12: T4=12−2+1=−12T_4 = \tfrac12 - 2 + 1 = -\tfrac12 and cos⁡(4π/3)=−12\cos(4\pi/3) = -\tfrac12. (b) With x=cos⁡θx = \cos\theta the weight cancels dxdx: the integral is ∫0πcos⁡θcos⁡3θ dθ=12∫0π(cos⁡4θ+cos⁡2θ) dθ=0\int_0^\pi\cos\theta\cos3\theta\,d\theta = \tfrac12\int_0^\pi(\cos4\theta + \cos2\theta)\,d\theta = 0, and ∫0πcos⁡23θ dθ=π2\int_0^\pi\cos^23\theta\,d\theta = \tfrac\pi2.

✏️ Pen & paperThe two-point Gauss rule●●○

Find the nodes ±a\pm a and equal weights ww for a two-point rule on [−1,1][-1, 1] exact for 1,x,x2,x31, x, x^2, x^3. Apply it to ∫−11ex dx\int_{-1}^1e^x\,dx and compare with the exact 2.35040242.3504024.

Show worked solution

Exactness for 11 gives 2w=22w = 2, so w=1w = 1. For x2x^2: 2a2=232a^2 = \tfrac23, so a=1/3=0.57735a = 1/\sqrt3 = 0.57735, the zeros of P2=12(3x2−1)P_2 = \tfrac12(3x^2-1). Odd powers vanish by symmetry, so xx and x3x^3 are exact too. The rule gives e0.57735+e−0.57735=2cosh⁡(0.57735)=2.34270e^{0.57735} + e^{-0.57735} = 2\cosh(0.57735) = 2.34270. The error is 2.3504024−2.3427=7.7×10−32.3504024 - 2.3427 = 7.7\times10^{-3}, the sim’s n=2n = 2 value 7.71×10−37.71\times10^{-3}.

✏️ Pen & paperHow long does a pipe flow remember its profile?●○○

A pipe of radius R=2R = 2 cm carries oil with ν=5×10−5\nu = 5\times10^{-5} m2^2/s. After the pressure gradient is switched off, how long until the first-mode part of the centerline speed has dropped by a factor ee?

Show worked solution

The first mode decays as exp⁡(−j12νt/R2)\exp(-j_1^2\nu t/R^2) with j12=5.7832j_1^2 = 5.7832, so the time is t=R2/(j12ν)t = R^2/(j_1^2\nu). With R2=4×10−4R^2 = 4\times10^{-4} m2^2: t=4×10−4/(5.7832×5×10−5)=1.38t = 4\times10^{-4}/(5.7832\times5\times10^{-5}) = 1.38 s. Higher modes decay faster (30.4730.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 / ⁣∫yk2wc_k = \int fy_kw\,\big/\!\int y_k^2w; the weight must be the problem’s weight or the basis is not orthogonal (wrong-weight Gram entries up to 0.930.93).
  • Legendre (w=1w = 1), Chebyshev (w=1/1−x2w = 1/\sqrt{1-x^2}), Hermite (e−x2e^{-x^2}) and Laguerre (e−xe^{-x}) polynomials are generated by three-term recurrences, which orthogonality forces; P5(0.3)=0.34538625P_5(0.3) = 0.34538625.
  • x=cos⁡θx = \cos\theta makes a Chebyshev series a cosine series with the FFT, and removes the endpoint seam: for exe^x the Chebyshev max error is 2.6×10−112.6\times10^{-11} at N=10N = 10 against 1.191.19 for period-2 Fourier.
  • The smoothness rule survives: rms slopes about −1.4-1.4 for a corner and −0.5-0.5 for a jump, geometric convergence for analytic functions at a rate set by the nearest complex singularity (Runge: ρ=1.2198\rho = 1.2198).
  • Fourier-Bessel series on a disc use the weight rr and the zeros of J0J_0 (2.404826, 5.520078, …2.404826,\ 5.520078,\ \dots); they give drum frequency ratios 1,2.2954,3.59851, 2.2954, 3.5985 and pipe spin-down rates jk2ν/R2j_k^2\nu/R^2.
  • Convergence is fast only if ff satisfies the basis’s boundary conditions: 1−r21 - r^2 gives slope −2.47-2.47, f=1f = 1 gives −0.49-0.49.
  • An nn-point Gauss-Legendre rule is exact through degree 2n−12n - 1 because its nodes are zeros of PnP_n; for exe^x five points give error 8.3×10−108.3\times10^{-10} against 4.9×10−24.9\times10^{-2} for the trapezoid rule.
  • Chebyshev points tame the Runge phenomenon (interpolation error 0.1320.132 at n=10n = 10 against 1.921.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.

Where this leads

These later lessons build directly on this one: