Spectral Methods
Pdes
Spectral methods represent the unknown function in a GLOBAL basis of smooth functions — typically Fourier modes on periodic domains, Chebyshev polynomials on intervals, spherical harmonics on the sphere — rather than as values on a mesh. Derivatives are computed by differentiating the basis functions exactly; the discrete problem is a linear system in the coefficient space. The defining property of spectral methods: for SMOOTH solutions, the error converges FASTER than any polynomial rate in the number of basis functions — SPECTRAL or EXPONENTIAL convergence. A 32-point Chebyshev spectral solve can match the accuracy of a several-thousand-point finite-difference solve when the underlying solution is smooth.
The canonical reference is J. P. Boyd's Chebyshev and Fourier Spectral Methods (Dover, 2001) — by the same author whose "Devil's Invention" review anchors the hyperasymptotics page. Boyd's book is the standard practical guide and is freely available online from his website.
Why spectral convergence
For a function on , the Chebyshev-coefficient expansion has coefficients decaying like — fast for high-regularity . For a function the coefficients decay FASTER than any polynomial, and for an ANALYTIC function (extension to a strip around in the complex plane) they decay EXPONENTIALLY: for some .
Truncating the series after terms gives error for analytic functions — exponential decay in . Finite differences give algebraic decay for some fixed integer . Algebraic vs exponential is the same gap as polynomial vs exponential, and it is the entire reason spectral methods are unbeatable on smooth problems.
The catch: for non-smooth solutions (shocks, kinks, jumps), spectral convergence DEGRADES. Discontinuities produce coefficient decay (Gibbs phenomenon), giving the same convergence as a first-order finite-difference scheme — or worse, oscillations near the discontinuity. Spectral methods shine for smooth problems and require careful handling for problems with shocks.
Chebyshev collocation
Among the spectral families, Chebyshev polynomials are the workhorse for non-periodic problems on a bounded interval. Two reasons. (1) The Chebyshev grid for clusters near the endpoints ( spacing) — exactly what's needed to avoid the Runge phenomenon (polynomial interpolation at equispaced nodes gives wild oscillations near the endpoints). (2) Differentiation in this basis can be computed by a DIFFERENTIATION MATRIX: a dense matrix such that equals for any polynomial of degree sampled at the Chebyshev nodes.
The differentiation matrix has explicit entries (Canuto-Hussaini-Quarteroni-Zang; Trefethen's textbook Spectral Methods in MATLAB):
with and for . The diagonal entries are determined by the requirement that annihilate constants (). This is the negative-sum trick — the cleanest way to compute diagonals stably.
Higher derivatives are obtained by repeated application: for polynomials of degree . Dirichlet boundary conditions are imposed by STRIPPING the first and last rows and columns of (which correspond to the boundary points) — the resulting linear system is solved for the interior unknowns. Other boundary conditions can be enforced by modifying the boundary rows directly.
Code: 1D Poisson with spectral convergence
A concrete benchmark. Solve on with , choosing as the exact solution (a smooth, oscillatory profile that satisfies the boundary conditions automatically), and check the error at several discretization sizes.
# Chebyshev spectral collocation for 1D Poisson on [-1, 1].
#
# -u''(x) = f(x), u(-1) = u(1) = 0.
#
# Discretize on the Chebyshev nodes x_k = cos(k pi / N) and approximate
# differentiation by the (N+1)x(N+1) Chebyshev differentiation matrix D.
# Then D² approximates d²/dx². Apply BCs by stripping the boundary rows
# and columns. Solve the resulting (N-1)x(N-1) linear system.
#
# Choose a smooth test problem: exact u(x) = (1 - x²) cos(5 x).
# Compute f(x) = -u''(x) analytically, run the solver at several N,
# observe the EXPONENTIAL convergence in N (until round-off floors).
import numpy as np
def cheb_diff_matrix(N):
"""Trefethen's cheb.m. Returns (N+1)x(N+1) differentiation matrix
and the Chebyshev nodes x_k = cos(k pi / N), k = 0, ..., N."""
if N == 0:
return np.zeros((1, 1)), np.array([1.0])
x = np.cos(np.pi * np.arange(N + 1) / N)
c = np.array([2.0] + [1.0]*(N - 1) + [2.0]) * (-1)**np.arange(N + 1)
X = np.tile(x, (N + 1, 1)).T
dX = X - X.T
D = np.outer(c, 1.0/c) / (dX + np.eye(N + 1))
D -= np.diag(D.sum(axis=1))
return D, x
def u_exact(x):
return (1 - x**2) * np.cos(5 * x)
def f_rhs(x):
"""f = -u'' for u = (1 - x²) cos(5 x)."""
# u' = -2 x cos(5x) - 5 (1 - x²) sin(5x)
# u'' = -2 cos(5x) + 20 x sin(5x) - 25 (1 - x²) cos(5x)
return 2*np.cos(5*x) - 20*x*np.sin(5*x) + 25*(1 - x**2)*np.cos(5*x)
print("Chebyshev solve: -u'' = f, exact u(x) = (1-x²) cos(5x), u(±1) = 0")
print(f" {'N':>5s} {'||err||_inf':>14s}")
for N in [8, 12, 16, 20, 24, 32, 48, 64]:
D, x = cheb_diff_matrix(N)
D2 = D @ D
# Strip the boundary rows and columns (Dirichlet u(±1) = 0)
D2_int = D2[1:-1, 1:-1]
u_int = np.linalg.solve(-D2_int, f_rhs(x[1:-1]))
u = np.zeros(N + 1)
u[1:-1] = u_int
err = np.max(np.abs(u - u_exact(x)))
print(f" {N:>5d} {err:>14.4e}")
print("(Error drops by orders of magnitude per refinement — spectral convergence.)") Output:
Chebyshev solve: -u'' = f, exact u(x) = (1-x²) cos(5x), u(±1) = 0
N ||err||_inf
8 2.9938e-02
12 8.5614e-05
16 3.7458e-08
20 8.1330e-12
24 6.1062e-14
32 2.3315e-15
48 2.2538e-14
64 6.3949e-14
(Error drops by orders of magnitude per refinement — spectral convergence.) Three orders of magnitude per increment of 4. Reaching machine precision (~) at — twenty-five degrees of freedom for fourteen digits of accuracy. Compare to finite differences on the same problem: hitting with central second-order FD would need grid points (since FD error , and ). Six orders of magnitude fewer degrees of freedom for the same accuracy. The error floors at at the round-off limit — the conditioning of scales like , so accuracy beyond is gradually lost; with the negative-sum trick we still squeeze out .
Fourier spectral methods on periodic domains
For periodic boundary conditions, the natural basis is plain Fourier modes . Differentiation in this basis is MULTIPLICATION BY in coefficient space:
With the FFT, you can transform between physical and Fourier representations in — so a typical spectral time-step on a periodic domain costs , beating any local-stencil method's cost by only a log factor while delivering exponential accuracy in . The operator splitting page uses this for the kinetic part of the time-dependent Schrödinger equation.
What spectral methods are good for
- Smooth solutions on simple geometries: rectangle, annulus, sphere, periodic box, etc. Climate codes, turbulence simulation in periodic boxes, plasma physics, geophysical fluid dynamics — all use spectral methods at the highest-accuracy end.
- Eigenvalue problems: spectral discretization of gives a dense small eigenvalue problem with exponentially-accurate eigenpairs. Routine in hydrodynamic stability analysis and quantum mechanics.
- Periodic Schrödinger / quantum dynamics: split-step Fourier methods (see TDSE) treat the kinetic operator exactly in Fourier space, achieving spectral accuracy for the spatial discretization.
- Pseudo-spectral methods for nonlinear PDEs: evaluate nonlinearities (e.g. ) in physical space, evaluate derivatives in Fourier space; the workhorse for incompressible Navier-Stokes simulations in periodic geometries.
What they're bad for
- Complex geometry: spectral methods need the geometry to match the basis. Use finite elements, spectral elements (high-order FE), or DG methods on unstructured meshes.
- Shocks and discontinuities: Gibbs oscillations destroy the spectral convergence and pollute the solution far from the discontinuity. Limiter techniques and filtered spectral methods help but rarely match the elegance of WENO finite-volume methods for shock-dominated problems.
- Very stiff problems: the differentiation matrix has condition number for the second derivative; ill-conditioning can be a problem at very high .
- Adaptive mesh refinement: spectral methods are global; refining "locally" is awkward. Spectral elements are the standard fix.
Related
- Separation of variables — spectral methods are the numerical embodiment of the same eigenfunction-expansion philosophy.
- Finite difference methods — the algebraic-convergence alternative.
- Finite elements — global vs local basis functions; spectral elements bridge the two.
- Time-dependent Schrödinger — split-step Fourier method is a spectral time integrator.
- Hyperasymptotics — Boyd's other major contribution; both topics share his pedagogical style and connect through the analytical-vs-numerical theme.