Spectral Method
Theory: representing functions as sums of waves
Overview
Spectral methods are said to be very accurate. How do they differ from finite differences?
A finite difference computes a derivative at a point from a few nearby values. A spectral method represents values across the whole domain as a sum of waves (sines and cosines), differentiates each wave exactly and sums them back. Finite differences misrepresent the speed and shape of fine waves, while spectral methods handle every representable wave exactly. So for smooth solutions, error drops rapidly with more points. Using every point makes complex geometry awkward, though, and discontinuities produce oscillations.
Differentiation by Fourier series
Coefficients come from the fast Fourier transform (FFT), costing about N log N for N points. For non-periodic problems, Chebyshev polynomials are used with points clustered toward both ends.
Modified wavenumber
Finite differencing treats a wave of wavenumber k as if it had k′. The larger kh (fewer points per wavelength), the smaller k′ and the slower the wave travels. Spectrally, k′ = k.
The method behind turbulence DNS
In 1972 Orszag and Patterson computed turbulence in a periodic box directly with a spectral method. In 1987 Kim, Moin and Moser computed turbulent channel flow combining Fourier series and Chebyshev polynomials; their results are still widely used to validate turbulence models. Spectral accuracy let limited grid points represent the finest eddies faithfully, and the invention of the FFT in 1965 made it practical.
Worked examples
Example 1: max derivative error of exp(sin x) (period 2π)
| Points | Spectral | 2nd-order FD | 4th-order FD |
|---|---|---|---|
| 8 | 4.3×10⁻³ | 3.4×10⁻¹ | 1.4×10⁻¹ |
| 16 | 1.8×10⁻⁷ | 9.4×10⁻² | 1.6×10⁻² |
| 32 | 3.8×10⁻¹⁵ | 2.6×10⁻² | 1.1×10⁻³ |
| 64 | 9.4×10⁻¹⁵ | 6.5×10⁻³ | 7.6×10⁻⁵ |
Doubling points cuts finite-difference error by 4 (2nd order) or 16 (4th order), while the spectral error hits round-off at 32 points and goes no lower.
Example 2: points per wavelength for correct wave speed
| Method | Within 1% | Within 0.1% |
|---|---|---|
| 2nd-order FD | 25.6 | 81.1 |
| 4th-order FD | 8.3 | 15.0 |
| 6th-order FD | 5.7 | 8.6 |
| Spectral | Exact above 2 | Same |
In 3D point counts are cubed. Second-order FD at 1% (25.6 points) versus spectral at about 3 points per wavelength including dealiasing differ by about 620 times in grid points for the same wave.
Example 3: a non-periodic function (Chebyshev)
| Points | Chebyshev | Uniform 2nd-order FD |
|---|---|---|
| 17 | 6.5×10⁻¹ | 7.9×10⁻¹ |
| 33 | 5.4×10⁻² | 3.5×10⁻¹ |
| 65 | 1.9×10⁻⁴ | 9.3×10⁻² |
Derivative of 1/(1 + 25x²) on [−1, 1]. For a rapidly varying function, even the spectral method errs badly with few points, but the error drops quickly once there are enough.
With few points, Chebyshev and finite differences aren't so different.
Right. Fast spectral convergence appears only once there are enough points to represent the finest variation. Here the fine structure is the peak about 0.2 wide near x = 0, which 17 points can't capture. Going four times finer to 65 points cuts the finite-difference error by about 9 but the Chebyshev error by about 3,500. DNS is the same: without a grid that resolves the smallest eddies, spectral advantages don't appear. Conversely, a true discontinuity like a shock can never be captured however many points are added, leaving Gibbs oscillations.
Where to use it and caveats
- Use for simple geometry (periodic box, channel, pipe) with smooth solutions.
- Compute nonlinear products in physical space and dealias (e.g. 3/2 rule).
- Use Chebyshev polynomials in non-periodic directions.
- Chebyshev points cluster tightly at the ends; watch explicit time steps.
- For complex geometry consider spectral element or high-order FE methods.
“A DNS whose energy kept rising”
A spectral DNS of turbulence in a periodic box saw kinetic energy, which viscosity should steadily reduce, start rising at some point and blow up. The cause was aliasing in the nonlinear term: when velocity products were computed in physical space, unrepresentable fine waves masqueraded as coarse waves, injecting energy. Adding the 3/2 rule (computing products on 1.5 times as many points) made energy decrease monotonically. Being so accurate, spectral methods have no numerical viscosity to hide such errors, so they show up clearly.
Common mistakes
Mistakes and fixes
| Mistake | Effect | Fix |
|---|---|---|
| No dealiasing | Energy grows, blow-up | 3/2 rule |
| Used on discontinuities | Gibbs oscillations | Finite-volume etc. |
| Fourier in non-periodic direction | Large boundary errors | Chebyshev |
| Smallest scales unresolved | No accuracy gain | Revise grid |
| Large step with Chebyshev | Explicit instability | Use implicit terms |
I'd like to learn related topics.
Related pages include central differencing, finite-volume fundamentals, time integration in CFD, multigrid and density-based solvers.
Related Topics
Experience the theory firsthand with the interactive simulator for this field
All Simulators