Fourier Series Synthesiser
Animated phasor chains build classic waveforms harmonic by harmonic — adjust N and watch the Gibbs phenomenon
Fourier Series: Any Periodic Function as Sines and Cosines
In 1822, Joseph Fourier proved that virtually any periodic function can be reconstructed as an infinite sum of sines and cosines. This is one of the most powerful and far-reaching results in all of mathematics, with applications in signal processing, quantum mechanics, heat conduction, image compression (JPEG), audio (MP3), and hundreds of other fields.
where the Fourier coefficients are:
aₙ = (1/π) ∫₋π^π f(x) cos(nx) dx bₙ = (1/π) ∫₋π^π f(x) sin(nx) dx
Analytic Formulae for the Six Presets
| Waveform | Fourier Series | Coeff decay |
|---|---|---|
| Square | (4/π)·[sin x + sin 3x/3 + sin 5x/5 + …] (odd harmonics only) | O(1/n) |
| Sawtooth | (2/π)·[sin x − sin 2x/2 + sin 3x/3 − …] (all harmonics, alternating sign) | O(1/n) |
| Triangle | (8/π²)·[sin x − sin 3x/9 + sin 5x/25 − …] (odd n, alternating) | O(1/n²) |
| Half-Wave Rect | 1/π + sin x/2 + (2/π)·[cos 2x/3 − cos 4x/15 + …] | O(1/n²) |
| Pulse (d=25%) | 0.25 + Σ (2sin(nπd)/nπ)·cos(nx), d=¼ | O(1/n) |
| Custom | Numeric DFT of drawn curve (512 samples) | Depends on smoothness |
Notice the coefficient decay rates. For smooth functions (like the triangle wave, which is C⁰ but not C¹), coefficients decay at least as fast as O(1/n²). For discontinuous functions (square, sawtooth), they decay only as O(1/n). This slow decay is directly responsible for the Gibbs phenomenon — the partial sums need many terms to "resolve" the sharp jump.
The Gibbs Phenomenon
Set the preset to Square wave and increase N from 1 to 50. The partial sum approximation becomes sharper and sharper near the discontinuity — but the overshoot peak never disappears. No matter how large N becomes, the maximum overshoot remains approximately 8.9% of the jump height.
The overshoot does shrink in width — it concentrates into an ever-thinner spike near the discontinuity — but its height converges to the Gibbs constant, not zero. This matters for signal processing: Gibbs ringing in bandlimited reconstructions causes artefacts, motivating window functions (Hann, Hamming) and Fejér summation methods.
Phasor Representation
Every sinusoidal term aₙcos(nx) + bₙsin(nx) can be written as a single rotating vector (phasor) of radius Aₙ =√(aₙ²+bₙ²) rotating at angular speed n. Chaining these phasors tip-to-tail — as shown on the left panel — is exactly the animation in the simulator. The y-coordinate of the final phasor tip traces the Fourier partial sum over time.
Convergence Theory
- Dirichlet conditions (1829): if f is bounded, has finitely many extrema and discontinuities in each period, the Fourier series converges to f(x) at continuity points and to [f(x⁺)+f(x⁻)]/2 at jump discontinuities.
- Parseval's identity: (1/π)∫|f(x)|² dx = a₀²/2 + Σ(aₙ²+bₙ²) — the total energy splits across harmonics.
- L² completeness: the trigonometric system {1, cos nx, sin nx} forms a complete orthonormal basis for L²(−π,π). Every square-integrable function is its Fourier series in the L² sense.
- Uniform convergence: if f is continuous and piecewise smooth, the series converges uniformly (no Gibbs phenomenon).
- Fejér's theorem: Cesàro means (averages of partial sums) converge uniformly for any continuous periodic function, providing a summation method that avoids Gibbs overshoot.
Applications
- Signal processing: Audio equalisation uses Fourier decomposition; MP3 compression discards inaudible harmonics; waveform synthesis in synthesisers adds harmonics to build timbres
- Heat equation: Fourier introduced his series specifically to solve ∂u/∂t = α∇²u — separating variables yields Fourier modes that decay exponentially, and any initial condition u(x,0) = f(x) expands in the Fourier series
- Quantum mechanics: Schrödinger eigenstates in a box are Fourier modes; any initial wavefunction ψ(x,0) is a Fourier series in those eigenstates
- Image compression: JPEG uses the Discrete Cosine Transform (a relative of Fourier series); images are stored as 8×8-block DCT coefficients
- Optics: A diffraction grating's far-field pattern is the Fourier transform of the aperture function
- Number theory: Dirichlet characters and L-functions use Fourier analysis on finite groups (Z/nZ)
Frequently Asked Questions
Why do square and sawtooth waves have only O(1/n) decay?
What is the difference between Fourier series and the Fourier transform?
Why can the same phasor idea draw arbitrary shapes (like letters)?
Part of MySimulator.uk — 55+ interactive simulations · Read: Measure Theory · All Simulations