The Fourier Series

You now know how to compute a single Fourier coefficient — one number telling you exactly how much of one particular sine or cosine wave sits inside a function. But nobody wants a function rebuilt one ripple at a time; the payoff comes from putting every coefficient's piece together into a single formula. That formula is the Fourier series of a periodic function f of period 2L:

f(x) = \frac{a_0}{2} + \sum_{n=1}^{\infty}\Big(a_n\cos\frac{n\pi x}{L} + b_n\sin\frac{n\pi x}{L}\Big).

The constant a_0/2 sets the average level; each n adds a ripple of frequency n\pi/L in just the amount the coefficient prescribes. Truncating after N terms gives a partial sum S_N(x) — a finite, smooth approximation that improves as N grows.

Worked example: assembling the square wave

Recall the square wave from the previous page: f(x) = +1 where \sin x > 0 and -1 where it is negative. We already computed its coefficients by hand — every a_n = 0, and b_n = \frac{4}{n\pi} on odd n, zero otherwise: b_1 = \frac{4}{\pi} \approx 1.273, b_3 = \frac{4}{3\pi} \approx 0.424, b_5 = \frac{4}{5\pi} \approx 0.255. Now we simply plug them into the general formula above and start stacking terms:

S_1(x) = \frac{4}{\pi}\sin x \approx 1.273\sin x. S_2(x) = \frac{4}{\pi}\sin x + \frac{4}{3\pi}\sin 3x \approx 1.273\sin x + 0.424\sin 3x. S_3(x) = \frac{4}{\pi}\sin x + \frac{4}{3\pi}\sin 3x + \frac{4}{5\pi}\sin 5x \approx 1.273\sin x + 0.424\sin 3x + 0.255\sin 5x.

In closed form, continuing this pattern forever gives the full series for the square wave:

f(x) = \frac{4}{\pi}\Big(\sin x + \frac{\sin 3x}{3} + \frac{\sin 5x}{5} + \cdots\Big) = \frac{4}{\pi}\sum_{k\ \text{odd}}\frac{\sin kx}{k}.

Sketch S_1 and it is just a gentle sine wave — nothing square about it yet. Add the \sin 3x term to get S_2 and the curve already starts to flatten across the top and steepen at the crossing. Keep adding odd harmonics and the shape drives ever closer to two flat steps joined by a near-vertical wall — the astonishing claim that sharp, flat-topped steps can emerge from nothing but smooth sine waves, right there in the arithmetic.

A quick sanity check, away from any jump: at x = \pi/2 the target function is smoothly f(\pi/2) = +1 (since \sin(\pi/2) > 0). Plugging into S_3: 1.273\sin\frac{\pi}{2} + 0.424\sin\frac{3\pi}{2} + 0.255\sin\frac{5\pi}{2} = 1.273(1) + 0.424(-1) + 0.255(1) \approx 1.104. Already close to 1 with just three terms, and it keeps creeping closer with every harmonic added — ordinary, well-behaved convergence, exactly as promised. Hold that thought, because the corner is about to behave very differently.

But look closely at the corner where the wave jumps from -1 to +1, no matter how many terms you add. There's a small overshoot — the curve pokes just above +1 before settling back down. Adding more terms squeezes that overshoot into a narrower and narrower sliver near the jump, but it never fully disappears. This famous wrinkle — the Gibbs phenomenon — is a genuine feature of how Fourier series behave at a jump, explored properly in convergence of Fourier series.

Building sound one wave at a time

Musicians and audio engineers construct exactly this kind of sum for a living, just with sound instead of ink. A technique called additive synthesis builds a rich, complex musical timbre by mixing together a bank of pure, simple sine-wave oscillators — one tuned to the fundamental pitch, others tuned to its harmonics (double the frequency, triple, and so on) — each turned up or down to its own volume.

That is a Fourier series, built in real time out of physical hardware or software instead of symbols on a page: the fundamental oscillator plays the role of the n=1 term, the second-harmonic oscillator the n=2 term, and each oscillator's volume knob is exactly a coefficient like a_n or b_n. Turn up the third harmonic and you brighten the sound in precisely the way raising b_3 reshapes the curve above. A trumpet, a clarinet, and a violin playing the very same musical note sound utterly different from one another for exactly this reason: same fundamental frequency, wildly different mixture of harmonic coefficients.

Push the idea further and you get a genuinely striking demo: mix a fundamental with just its odd harmonics at 1, \tfrac13, \tfrac15, \ldots the fundamental's volume — the very same coefficients computed for the square wave above — and the resulting tone starts to sound noticeably "buzzier" and more hollow than a pure sine, edging towards the harsh, reedy character of a clarinet. Change the recipe of harmonics and you change the instrument, all without touching the pitch.

Add the harmonics

The faint dashed line is the target square wave; the bold curve is the partial sum S_N using the first N odd harmonics — exactly the S_1, S_2, S_3, \ldots built by hand above, just carried further. Raise N and the approximation hugs the steps ever more tightly — flat where the wave is flat, snapping over at each jump — while that small overshoot at the corners stubbornly refuses to shrink away.

Symmetry saves work. If f is even (f(-x) = f(x)), every b_n = 0 and only cosines appear. If f is odd (f(-x) = -f(x)), every a_n = 0 and only sines appear — which is why the odd square wave is a pure sine series. Spotting symmetry first can halve the integrals you actually have to do.

A truncated (finite-term) Fourier series is only an approximation — and near a sharp jump or discontinuity, it behaves in a way that surprises almost everyone the first time they see it.

Long before digital synthesizers, the Hammond organ — a fixture of church halls, jazz clubs and rock bands since the 1930s — built its sound with a row of sliding drawbars, each one wired to a spinning metal "tonewheel" tuned to one particular harmonic. Pull a drawbar out and you turn up that harmonic's coefficient; push it in and that harmonic vanishes from the mix. A player dialling in a smooth, flute-like tone or a buzzy, reed-like growl was — whether they knew it or not — hand-setting a row of Fourier coefficients in real time, decades before anyone thought to build the same trick out of silicon.

Modern software synthesizers still ship an "additive" oscillator bank that does exactly the same job with a mouse instead of a mechanical lever — proof that a two-hundred-year-old piece of maths turned into one of the most enduring ideas in electronic music.

See it explained