Skip to main content

Module spectral

Module spectral 

Source
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.

See the book entry Spectral methods.

Functions§

chebyshev_bvp
Solves u'' + p(x) u' + q(x) u = f(x) on [a, b] with u(a) = ua, u(b) = ub by Chebyshev collocation at n + 1 points. Returns the points (from b down to a) and the solution.
chebyshev_differentiation_matrix
The (n+1) × (n+1) differentiation matrix on chebyshev_points: (D u)_i ≈ u'(x_i), exact for polynomials of degree n. The diagonal uses the negative-row-sum trick for accuracy.
chebyshev_points
The n + 1 Chebyshev-Gauss-Lobatto points x_j = cos(πj/n), from 1 down to −1.
fourier_derivative
The order-th derivative of the periodic function sampled at u.len() equispaced points over one period length, 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_xx with periodic boundaries over length exactly in Fourier space: each mode decays by e^{−α k² t}. Exact in time and spectrally accurate in space.