Fourier decomposition is one of those concepts you can study for years and still not have it click until you try it visually. So instead of explaining it, this post hands you the knobs. Four steps, no math required, though the math is sitting right underneath if you want it.
1. Meet one sine wave
Everything here is built out of one ingredient. A sine wave has three dials: how tall it is (amplitude), how many times it repeats in the window (frequency), and where in its cycle it starts (phase). Play with them until they feel boring. That’s the point — they should be boring.
Step 1 · One wave
tip: double-tap any slider to put it back
2. Now build a square wave out of them
Here’s the claim that sounds wrong the first time you hear it: add up enough smooth, round sine waves and you can make a square wave — flat tops, sharp corners and all. You get eight sine waves to work with — the same eight frequencies the Frequency slider in step 1 stepped through, 1× up to 8×. Phase is locked at zero for all of them (the square starts its cycle at the same moment every one of these waves does, so there’s nothing to shift), which leaves one dial per wave: amplitude, or how much of that frequency goes into the mix. The dashed line is the target. See how close you can get.
Step 2 · Match the square
If you got close, you probably found the pattern on your own: only the odd frequencies matter, and their amplitudes shrink — 1, ⅓, ⅕, ⅐ of the first. That recipe is the square wave. Fourier’s actual insight is that every repeating shape has a recipe like that, and there’s exactly one right answer for it.
The reason there’s exactly one answer is that sine waves at different frequencies form an orthogonal basis: multiply any two of them together, average over a full cycle, and you get zero. Each one measures something the others can’t see — which is why, once you found the right height for 1×, adding 3× never changed what the right height for 1× was. That’s the thread to pull if you want to go deeper: it’s the same idea as x, y and z axes being at right angles, just with infinitely many axes.
3. Draw anything
You don’t have to find the recipe by hand, though. The Fourier transform reads it straight off the shape. Draw whatever you want in the box below (or pick a preset), then slide the number of waves up from 1. The bars underneath are the recipe — how much of each wave the shape needs. Lit bars are the ones currently in use.
Step 3 · Draw, then decompose
dashed = what you drew · solid = rebuilt from sine waves · bars = how much of each wave, 1× to 64×
A few things worth noticing while you play: smooth shapes (try the triangle) are basically done after a handful of waves, while anything with a sharp jump needs a long tail of them. And no matter how many you add to the square, the rebuild overshoots a little at every corner — that’s the Gibbs phenomenon, and it never fully goes away.
4. Use it on a real problem
Here’s where this stops being a party trick, and it’s something I’ve run into more than once while tinkering. You’re chasing noise in a setup, so you power everything down to see what the baseline looks like — and the scope is still showing this. Nothing’s running. Where is it coming from?
Step 4 · The scope with the power off
0.1 s of the trace ·
frequency, 0–1000 Hz · tap a peak to filter it out
In the time trace it’s fuzz with maybe a hint of a wobble. In the spectrum it’s a confession: a tall spike at exactly 60 Hz, smaller ones at 180, 300, 420 — odd multiples of 60 — and a low, flat carpet of everything else. Nothing in your experiment runs at 60 Hz, but the wall outlet does. That’s line noise: the building’s wiring is coupling into your setup, which almost always means something isn’t grounded or shielded the way you thought it was. (In most of the world outside North America you’d see the same picture at 50 Hz.)
Filtering those peaks out, like you just did, is the band-aid. The real fix is a ground strap or a shielded cable — but you wouldn’t have known which problem you had without looking at the recipe instead of the shape. That’s the whole trick, here and in the SVD signal extraction from my first post: most of a real signal lives in a few big bars, and once you can see them, you can decide which ones belong there.