Any periodic wave is a sum of sines
Joseph Fourier's 1807 claim — outrageous at the time — is that any reasonably well-behaved periodic function can be written as a sum of sines and cosines at integer multiples of its fundamental frequency. For a function f(x) with period 2π, that sum is:
f(x) = a₀/2 + Σ [aₙ·cos(nx) + bₙ·sin(nx)], n = 1, 2, 3, ... aₙ = (1/π) ∫ f(x)·cos(nx) dx over one period bₙ = (1/π) ∫ f(x)·sin(nx) dx over one period
Each term is a harmonic: n = 1 is the fundamental, n = 2 is the first overtone at twice the frequency, and so on. The coefficients aₙ and bₙ are found by projecting f onto each sine and cosine using the integral above — exactly the same operation as decomposing a vector into orthogonal components, because sines and cosines of different integer frequencies are orthogonal functions over one period.
Epicycles: the geometric picture
Every sine term aₙcos(nx) + bₙsin(nx) can be redrawn as a rotating arm of fixed length spinning at n times the base frequency. Chain enough of these arms tip-to-tail, each spinning at its own harmonic rate, and the tip of the last arm traces out the target waveform. This is the epicycle construction — the same geometric idea, incidentally, that Ptolemy used to model planetary motion, and the reason a Fourier series animation of a square or sawtooth wave looks like a cascade of spinning wheels drawing the curve in real time.
Square, sawtooth, triangle: three canonical series
Different target shapes need different harmonic content. A square wave of amplitude 1 uses only odd harmonics, decaying as 1/n:
square(x) = (4/π) · [ sin(x) + sin(3x)/3 + sin(5x)/5 + sin(7x)/7 + ... ]
A sawtooth uses every harmonic, odd and even, decaying at the same 1/n rate, while a triangle wave uses only odd harmonics but decays much faster, as 1/n². That faster decay is not a coincidence: a triangle wave is continuous with a well-defined slope almost everywhere, while a square wave jumps discontinuously, and the general rule is that the smoother the function, the faster its Fourier coefficients shrink — smoothness in x-space buys you sparsity in frequency space.
The Gibbs phenomenon
Truncate the square-wave series at any finite number of terms and something odd happens right at the jump: the partial sum overshoots the true value by about 9% of the jump height, no matter how many terms you add. Adding more harmonics narrows the region where the overshoot occurs but never shrinks its height — this is the Gibbs phenomenon, a direct consequence of trying to approximate a discontinuity with smooth, bounded oscillations. It shows up anywhere a sharp edge meets a truncated frequency representation, from audio clipping to JPEG ringing artefacts around hard edges.
Parseval's theorem: energy adds up in frequency space
Parseval's theorem says the total energy of a periodic signal, averaged over one period, equals the sum of the energy in each harmonic:
(1/2π) ∫ f(x)² dx = (a₀/2)² + (1/2) Σ (aₙ² + bₙ²)
This is the reason a frequency spectrum plot is meaningful at all: each bar's squared height is literally that harmonic's share of the signal's total power, and the bars sum exactly to the time-domain energy. It is also the theoretical basis for lossy audio and image compression — throw away the harmonics with the least energy and you lose the least perceptible information per bit saved.
Frequently asked questions
Why does a square wave need infinitely many harmonics to reproduce exactly?
Because a square wave has a genuine discontinuity, and a finite sum of smooth, continuous sine waves can only approximate a jump, never reproduce it exactly. Each additional odd harmonic narrows the transition region but a true vertical edge is only reached in the limit of infinitely many terms.
What causes the ringing you see near sharp edges when you cut off the harmonics?
That is the Gibbs phenomenon: truncating a Fourier series near a discontinuity always leaves an overshoot of about 9% of the jump size, however many terms you keep. It shrinks in width but not in height as you add harmonics, which is why sharp edges in audio or images show ringing artefacts under lossy compression.
How is Parseval's theorem useful in practice?
It guarantees the energy of a signal splits exactly between its harmonics, so a frequency spectrum is a literal power budget. Audio and image compression exploit this directly: harmonics carrying negligible energy can be discarded with minimal perceptual loss, which is the basic idea behind MP3 and JPEG encoding.
Try it live
Everything above runs in your browser — open Fourier Series and change the parameters while it is running. Nothing is installed, nothing is uploaded, the whole model lives in one tab.
▶ Open Fourier Series simulation