Fourier Synthesis of Waves

Pluck a guitar string, blow across the top of a bottle, hum a note: in every case the air pressure at your ear rises and falls in a pattern that repeats — a periodic wave. It is almost never a clean, smooth \sin curve. A bowed violin note looks jagged and rich; a plucked string has a sharp attack; a synthesiser buzzing out a "square wave" flips abruptly between two levels. And yet here is one of the most beautiful facts in all of physics: every one of those repeating shapes, no matter how complicated, is nothing more than a stack of ordinary sine waves added together.

This is Fourier synthesis. Take a single sine wave — the fundamental — and pile on top of it sine waves whose frequencies are exact whole-number multiples of it: twice the frequency, three times, four times, and so on. These multiples are the harmonics. Choose the amplitude of each harmonic carefully and the sum can be made to trace any periodic waveform you like — a square, a sawtooth, a triangle, the growl of a cello. The whole page rests on one sentence worth reading twice: any periodic wave is a sum of a fundamental sinusoid plus its harmonics. Below we will build a square wave with our bare hands out of sine waves, watch it sharpen up as we add terms, and discover that this same idea is the reason a flute and a violin playing the very same note still sound nothing alike.

The fundamental and its harmonics

Suppose the wave repeats f times a second — that is its fundamental frequency, measured in hertz (Hz). One full copy of the pattern takes a time T = 1/f, the period. The lowest sine wave that fits exactly into that period, oscillating once per cycle, is the fundamental:

y_1(t) = A_1 \sin(2\pi f t).

The next sine wave that also fits neatly into the same period is the one that oscillates exactly twice per cycle — frequency 2f. Then three times, at 3f, and so on. The n-th harmonic has frequency

f_n = n\,f, \qquad n = 1, 2, 3, \dots

The first harmonic (n=1) is the fundamental. The second harmonic sits an octave above it, the third a musical fifth above that, and so on up the harmonic series. Because every harmonic completes a whole number of cycles in the period T, their sum also repeats every T — the combined wave keeps the same fundamental frequency, no matter how many harmonics you add. All the harmonics do is change its shape.

Turning a known shape into its list of amplitudes is the job of the Fourier series, which supplies an integral recipe for each coefficient. Here we run the machine in reverse — we already know the amplitudes, and we synthesise the wave by adding the sinusoids back up.

Building a square wave from odd harmonics

Let us actually build one. A square wave — the buzzy tone of an early video-game — sits flat at +1, then jumps to -1, and back, forever. It is about as far from a smooth sine as a shape can be, so it is the perfect stress test. Its Fourier recipe is astonishingly tidy: only the odd harmonics appear (n = 1, 3, 5, 7, \dots), and the amplitude of each falls off as 1/n:

y(x) = \frac{4}{\pi}\left(\frac{\sin x}{1} + \frac{\sin 3x}{3} + \frac{\sin 5x}{5} + \cdots\right) = \frac{4}{\pi}\sum_{k=1}^{N}\frac{\sin\!\big((2k-1)x\big)}{2k-1}.

The even harmonics (2f, 4f, \dots) have amplitude exactly zero — they are simply absent. Drag the slider to add harmonics one at a time and watch the running total, the partial sum, climb towards the ideal square (drawn faintly behind it). With a single term you have just a lone sine. Add the third harmonic and the crests flatten; add the fifth, seventh, ninth and the sides grow steep and the top grows level. The more odd harmonics you stack, the sharper the corners and the flatter the plateaus — the sum is visibly converging on the square.

Notice what never quite goes away: right at each vertical jump the partial sum shoots past the target in a stubborn little spike before settling. That overshoot is real, and it has a name.

They never do. The little spike that overshoots the square at every jump is the Gibbs phenomenon, and it is the classic trap. Intuition says "add more terms and the error shrinks to nothing everywhere" — and almost everywhere that is true. But right at a discontinuity, the peak of the overshoot stays stuck at about 9% of the jump no matter how many harmonics you add. What does happen is that the spike gets narrower and narrower, sliding ever closer to the jump, so the area of the error vanishes. The height of the overshoot, though, is immortal.

The moral: a sum of finitely many smooth sines can get arbitrarily close to a sharp-cornered wave in the "average" sense, but it can never reproduce a true instantaneous jump perfectly with a finite number of terms. Real physical systems — a loudspeaker, an antenna — are band-limited (they carry only so many harmonics), so a "square" pulse always arrives with a touch of Gibbs ringing on its edges. It is not a bug in your maths; it is a fact about jumps.

Worked example: reading and summing a spectrum

Part 1 — which harmonics are present? A wave has fundamental frequency f = 220\ \text{Hz} (the note A below middle C). It is a pure square wave, so only odd harmonics survive. Their frequencies are

f_1 = 220,\quad f_3 = 3\times 220 = 660,\quad f_5 = 5\times 220 = 1100,\quad f_7 = 7\times 220 = 1540\ \text{Hz},

and so on — the even ones (440,\ 880,\ \dots\,\text{Hz}) are missing entirely. The general rule is simply f_n = n f: the seventh harmonic of a 220\ \text{Hz} note sits at 1540\ \text{Hz}.

Part 2 — evaluate a partial sum. Take the square-wave series above and add its first three terms (the first, third and fifth harmonics) at the point x = \tfrac{\pi}{2}, where the ideal square wave sits at +1. At that point \sin(\tfrac{\pi}{2}) = 1, \sin(\tfrac{3\pi}{2}) = -1, \sin(\tfrac{5\pi}{2}) = 1, so

y \approx \frac{4}{\pi}\left(\frac{1}{1} - \frac{1}{3} + \frac{1}{5}\right) = \frac{4}{\pi}\left(1 - 0.333 + 0.200\right) = \frac{4}{\pi}\,(0.867) \approx 1.104.

Three terms already overshoot the target of 1 — that 1.10 is the Gibbs bump in action. Keep going and the value at x=\tfrac{\pi}{2} settles back towards 1, because that point is not at the jump; it is the sample points creeping right up to the discontinuity that keep the stubborn spike alive.

Harmonics and timbre: why a violin isn't a flute

Now the payoff. Play the note A at 440\ \text{Hz} on a flute and on a violin. Both have exactly the same fundamental frequency — that is what makes them the same note, the same pitch. Yet nobody would confuse the two for a moment. The difference is their timbre (say "TAM-ber"), the tone-colour, and Fourier synthesis tells us precisely what it is: the two instruments put different amounts of energy into their harmonics.

A flute is nearly a pure tone — a strong fundamental with only weak, quickly-fading harmonics, so its waveform is close to a smooth sine and its sound is soft and round. A violin's bowed string is buzzing with strong high harmonics (its waveform looks almost like a sawtooth), which is exactly why it sounds bright, edgy and full. A clarinet, closed at one end, suppresses its even harmonics much like our square wave — hence its distinctive hollow, woody colour. Same pitch, same loudness; different spectrum, different instrument. Your ear is, quite literally, a Fourier analyser: the cochlea separates an incoming sound into its harmonic components, and your brain reads the pattern of their strengths as the identity of the instrument.

It is tempting to think a "louder" or "higher" harmonic content just makes a note louder or higher. It does neither. Pitch is set by the fundamental frequency alone, and loudness by the overall amplitude. What the harmonic amplitudes control is the shape of the wave and hence its tone-colour — the thing that lets you recognise your friend's voice from a single "hello", or tell a trumpet from a trombone in a fraction of a second.

Here is the eerie proof: the "missing fundamental". Play a sound built from only the harmonics 200, 300, 400\ \text{Hz} — with no 100\ \text{Hz} tone present at all — and your brain still hears a pitch of 100\ \text{Hz}, because that is the fundamental those harmonics belong to. The pitch you perceive is a pattern your brain infers from the spacing of the harmonics, not necessarily a frequency physically in the air. Small phone speakers exploit exactly this to fake bass notes they are far too small to actually produce. Timbre is the harmonics; pitch is the pattern they imply.