// engineering › Fourier Waveforms

Square Wave Fourier Series

Build a square wave from odd harmonics and watch the Gibbs overshoot as you add terms.

y(t)=frac{4A}{pi}sum_{k=1,3,5,dots}^{N}frac{sin(komega t)}{k}

Formula

\[ y(t)=\frac{4A}{\pi}\sum_{k=1,3,5,\dots}^{N}\frac{\sin(k\omega t)}{k} \]

Square Wave — Odd Harmonics Only

Fourier series of a square wave (period T, amplitude A)

\[ y(t) = \frac{4A}{\pi} \sum_{k=1,3,5,\dots}^{N} \frac{\sin(k\omega t)}{k} \qquad \omega = \frac{2\pi}{T} \]

only odd harmonics amplitude decays as 1/k slow convergence ⇒ visible Gibbs ears at the edges

Reference: Wikipedia — Square wave; Wikipedia — Gibbs phenomenon. Derivation in Oppenheim, A. V., & Willsky, A. S. (1997). Signals and Systems, 2nd ed., §3.3.

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.