Fourier Series Calculator
Partial sums of the classic waveforms — square, sawtooth, triangle, parabola — with closed-form coefficients, the first coefficients listed, and the error at your x measured against the true function. Gibbs overshoot included, not hidden.
All four waveforms live on (−π, π) and repeat every 2π. Try the square wave at x = 1.5708 (π/2) with N = 5, then N = 99.
How we got it — the example, step by step
- Coefficients: bₙ = 4/(nπ) for odd n and 0 for even n, all aₙ = 0 — from integrating the wave against sin(nx) once, in closed form.
- At x = π/2 the sines alternate +1, −1, +1…, so the sum becomes (4/π)(1 − 1/3 + 1/5 − 1/7 + …) — the Leibniz series wearing a Fourier coat.
- With 99 terms that gives 0.9936. The remaining 0.0064 is not sloppiness: convergence at a fixed point away from the jump is genuinely this slow.
Check it backwards
Questions people also ask
Which waveforms are covered?
Four classics on (−π, π): the square wave, the sawtooth f(x) = x, the triangle f(x) = |x| and the parabola f(x) = x² — each with closed-form coefficients shown on the page. Arbitrary functions need numerical integration and are not covered yet.
Why is the square wave still off near its jump?
That is the Gibbs phenomenon: partial sums overshoot by about 8.95% of the jump height beside the discontinuity, at any number of terms. At the jump itself the series settles on the midpoint value.
What happens outside −π to π?
The series is 2π-periodic, so x is wrapped back into (−π, π) before comparing — the sawtooth's true value at x = 7 is 7 − 2π ≈ 0.7168.