Expand description
Spectral methods: Chebyshev collocation and Fourier differentiation.
For smooth solutions these converge exponentially fast in the number of points, far beyond the algebraic rates of finite differences and finite elements.
chebyshev_differentiation_matrixon the Chebyshev-Gauss-Lobatto points (Trefethen, Spectral Methods in MATLAB), andchebyshev_bvpsolvingu'' + p(x) u' + q(x) u = f(x)with Dirichlet ends by collocation.fourier_derivativeof periodic samples by the FFT, andperiodic_heat, which advances the periodic heat equation exactly in Fourier space.
See the book entry Spectral methods.
Functions§
- chebyshev_
bvp - Solves
u'' + p(x) u' + q(x) u = f(x)on[a, b]withu(a) = ua,u(b) = ubby Chebyshev collocation atn + 1points. Returns the points (frombdown toa) and the solution. - chebyshev_
differentiation_ matrix - The
(n+1) × (n+1)differentiation matrix onchebyshev_points:(D u)_i ≈ u'(x_i), exact for polynomials of degreen. The diagonal uses the negative-row-sum trick for accuracy. - chebyshev_
points - The
n + 1Chebyshev-Gauss-Lobatto pointsx_j = cos(πj/n), from 1 down to −1. - fourier_
derivative - The
order-th derivative of the periodic function sampled atu.len()equispaced points over one periodlength, by multiplying its spectrum by(ik)^order. For odd orders and even lengths the Nyquist mode is zeroed (its derivative is not representable). - periodic_
heat - Advances
u_t = α u_xxwith periodic boundaries overlengthexactly in Fourier space: each mode decays bye^{−α k² t}. Exact in time and spectrally accurate in space.