Build a Wave
Here's the idea the whole subject rests on: take a few sine waves — pure, smooth, boring — add them together, and out comes something sharp and jagged. A square wave. A sawtooth. Build it yourself and the magic stops being magic.
Smooth ingredients, sharp result
Each slider below controls the amount of one sine wave: sin x, sin 2x, sin 3x, and so on. Faster waves (higher numbers) add the fine, sharp detail. Add them up and you get:
Stack the sine waves 🎚️
Hit a target shape to auto-load its recipe, or drag the sliders yourself. Turn on "Show each harmonic" to see the individual sine waves that are being added up.
What to notice
More waves = sharper corners
With just sin x you get a gentle hump. Each higher harmonic you add pulls the curve closer to the sharp target. The corners need the fast waves — that's why a true square wave needs infinitely many.
The recipe is everything
A square wave uses only odd harmonics, each weaker than the last (1, ⅓, ⅕, …). Change the recipe and you change the shape. That list of amounts — one number per frequency — is the Fourier transform of the wave.
Look closely at the square wave near each vertical jump: there's a little overshoot that refuses to go away no matter how many harmonics you add. That's a real, famous effect — the Gibbs phenomenon — and you're seeing it live, not reading about it.