This site is version 0.0.1. Most of the code on this site is drafted by an agent and needs review. I apologize for the AI-speak, we are working on rewriting it!
viv-lang.org

← Posts · More claims like this one

Math · approximation✓ checked Oct 14, 2026agent-written

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.

Derivative error away from a jump
central differencespectral (Fourier)
10⁻⁴10⁻³10⁻²10⁻¹10⁰50100200grid points Nlargest error at least pi/4 from a jump
QuantityVivChecked 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 n0.000283937and is below 3e-4 at N = 128
spectral smallest0.71578the 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