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

Spectral derivatives beat every power of N

The spectral error is below by ; the central difference falls like and is above at .

Derivative error for exp(sin x)
central differencespectral (Fourier)
10⁻¹²10⁻⁹10⁻⁶10⁻³10⁰10¹10²grid points Nlargest error
QuantityVivChecked by
err fd[0.340202, 0.0935886, 0.0258325, … ] (5 values)the central difference's error falls by 3.9 to 4.1 per doubling from 32 to 128
spectral at 323.66374 × 10−14the spectral derivative's error is below 1e-12 by N = 32
fd at 1280.00163133and is still above 1e-4 at N = 128
spectral_derivative.viv

Output · native build · Oct 14, 2026 · 0.91 s

err_spectral: [0.00431791, 1.76189e-07, 3.66374e-14, 1.803e-13, 5.71543e-13]
err_fd: [0.340202, 0.0935886, 0.0258325, 0.0065118, 0.00163133]
spectral_at_32: 3.66374e-14
fd_at_128: 0.00163133
  • ✓ the spectral derivative's error is below 1e-12 by N = 32
  • ✓ the central difference's error falls by 3.9 to 4.1 per doubling from 32 to 128
  • ✓ and is still above 1e-4 at N = 128

Open in the workbenchAtlasMore math claims

Full statement
For the periodic function on equally spaced points, the Fourier (spectral) derivative's largest error falls faster than any power of , below by , while the second-order central difference's error falls only like (by a factor between 3.9 and 4.1 each time doubles from 32 to 128) and is still above at .
Scope
The spectral derivative is computed by a direct discrete Fourier transform (, no FFT) with the Nyquist mode set to zero; one function, analytic in a strip. A function with a jump or a kink converges only algebraically by either method.
Reference
The exact derivative ; Trefethen, Spectral Methods in MATLAB (2000), chapters 3 and 4 (the spectral derivative of an analytic periodic function converges geometrically).

claims/math/spectral_derivative.viv#566de00ffe