The Mathematics
The Fourier series of a periodic function f(t) with period T is:
f(t) = a₀/2 + Σ [aₙ cos(2πnt/T) + bₙ sin(2πnt/T)]
where the coefficients are:
aₙ = (2/T) ∫₀ᵀ f(t) cos(2πnt/T) dt
bₙ = (2/T) ∫₀ᵀ f(t) sin(2πnt/T) dt
For a square wave (odd symmetry, so all aₙ = 0):
f(t) = (4/π) [sin(ωt) + sin(3ωt)/3 + sin(5ωt)/5 + ...]
Only odd harmonics appear, each with amplitude 1/n. This 1/n decay is slow — that's why you need many terms to build a convincing square edge.
The Gibbs phenomenon
Notice the persistent overshoot at the corners? That's the Gibbs phenomenon — a mathematical inevitability. No matter how many terms you add, the partial sum overshoots by approximately 9% of the jump height at each discontinuity. The overshoot doesn't disappear; it just gets narrower. This is not a failure of Fourier analysis — it's a deep result about the tension between pointwise and uniform convergence.
Why epicycles?
The visualisation uses rotating circles (epicycles) because each Fourier term Aₙ sin(nωt + φₙ) is exactly a vector of length Aₙ rotating at angular velocity nω. Stack them tip-to-tail and the final point traces the partial sum. Ptolemy used the same geometry for planetary orbits — Fourier just gave it rigorous mathematical footing.
Further reading
- Fourier series (Wikipedia)
- 3Blue1Brown, But what is a Fourier series? — the definitive visual explanation.
- Stein & Shakarchi, Fourier Analysis: An Introduction, Princeton Lectures in Analysis.