⚠ Learning tool: waveforms are drawn by a browser script and may be imperfect
(floating-point rounding, finite-term truncation/Gibbs, rendering quirks). Treat as a visual aid, not an
authoritative reference; cross-check against a textbook or established software (Wolfram, MATLAB, SciPy).
Increase N and watch the partial sum sharpen toward the ideal square shape. The persistent overshoot at each jump
is the Gibbs phenomenon — it never disappears, even as N → ∞ (its height stays at about 9% of the jump),
it only gets narrower.
Frequently asked questions
Why does a square wave only contain odd harmonics?
A square wave has a special symmetry (it looks the same flipped and shifted by half a period), and that symmetry mathematically cancels every even harmonic. What is left is the 1st, 3rd, 5th... sine waves, each weaker than the last. Turn up N here and watch only the odd bars appear in the spectrum.
What are those little overshoots near the edges?
That is the famous Gibbs phenomenon. Near a sudden jump, the partial Fourier sum always overshoots by about 9% of the jump height — and it never goes away no matter how many harmonics you add; it just gets narrower. It is why perfectly sharp edges are impossible to reproduce with a finite number of frequencies.
Where do square waves show up in the real world?
Every digital clock signal inside your computer or phone is essentially a square wave — billions per second. So are PWM signals that dim LEDs and control motor speed. Understanding their harmonic content is how engineers stop those sharp edges from radiating interference into nearby radios and circuits.
Why do square waves sound 'buzzy' or 'hollow'?
Because they contain only odd harmonics, a square wave has a distinctive reedy timbre — close to a clarinet, which also favours odd harmonics. Classic video-game and synth sounds are built from square waves for exactly this reason. Compare it with the sawtooth tab to hear why 'all harmonics' sounds brighter.
How many harmonics do I need for a 'good' square wave?
There is no finite answer — a true square wave needs infinitely many. But the energy drops as 1/n, so the first 10–20 harmonics already look square to the eye. Drag N upward here and decide for yourself when it is 'square enough' — that engineering judgement is exactly what filter designers make every day.