Finite differences stay second order away from a jump
Away from the jumps the central difference error falls by 3.9 to 4.1 per doubling of ; the spectral error stays above 0.7.
central differencespectral (Fourier)
| Quantity | Viv | Checked by |
|---|---|---|
err fd | [0.00453478, 0.00113534, 0.000283937, … ] (4 values) | away from the jumps the central difference's error falls by 3.9 to 4.1 per doubling |
fd at n | 0.000283937 | and is below 3e-4 at N = 128 |
spectral smallest | 0.71578 | the spectral derivative's error at the same points stays above 0.7 for every N |
central_difference_near_a_jump.viv
Output · native build · Oct 14, 2026 · 0.77 s
err_spectral: [0.774325, 0.741519, 0.724424, 0.71578] err_fd: [0.00453478, 0.00113534, 0.000283937, 7.09905e-05] fd_at_n: 0.000283937 spectral_smallest: 0.71578
- ✓ away from the jumps the central difference's error falls by 3.9 to 4.1 per doubling
- ✓ and is below 3e-4 at N = 128
- ✓ the spectral derivative's error at the same points stays above 0.7 for every N
Open in the workbenchAtlasMore math claims
- Full statement
- For plus a unit step (jumps at and ), at the grid points at least from either jump, the second-order central difference's largest derivative error falls by a factor between 3.9 and 4.1 each time doubles from 32 to 256 and is below at , while the Fourier (spectral) derivative's error at the same points stays above 0.7 for every from 32 to 256.
- Scope
- One function, two jumps of size 1, N from 32 to 256 equally spaced points, the spectral derivative by a direct discrete Fourier transform (, no FFT) with the Nyquist mode set to zero. Near the jumps both methods fail (the largest error over all points grows like for both); this is about the points away from them. Filtering or a domain split at the jump restores spectral accuracy and is not tested here.
- Reference
- The exact derivative away from the jumps; Trefethen, Spectral Methods in MATLAB (2000), chapter 3 (the periodic spectral differentiation matrix has entries , which do not shrink as N grows) and Fornberg, A Practical Guide to Pseudospectral Methods (1996), on the loss of accuracy for nonsmooth data.
claims/math/central_difference_near_a_jump.viv#d783722817