Harmonic Synthesis and Fourier
Stack sines one by one into a square wave
The thick line is the sum of the sines added so far, and the faint dashed line is the square wave it should come to resemble. On the first button there is only the fundamental, so the thick line is a plain round sine. Each button to the right adds higher odd harmonics in turn; compare how closely the sum follows the flat top and steep edges of the dashed line.
Only integer-multiple frequencies qualify
To build a waveform of period T out of sines, every sine you add must also return to its starting shape every T. The only sines that do are those whose frequency is an integer multiple of the fundamental frequency, so the building blocks are frequencies 2, 3 or 4 times it, and so on. The sine at the fundamental frequency is called the fundamental and its integer multiples are the harmonics; pick the amplitude and phase of each harmonic correctly and the sum traces the shape you want. The calculation that tells you which amplitudes a given waveform needs is the Fourier series.
A square wave contains only odd harmonics
Shift a square wave by half a period and you get the same shape turned upside down. For a waveform like this the even harmonics all have amplitude 0, leaving only the odd ones, and the amplitude of the n-th harmonic shrinks as 1/n. So a square wave is written as sin(ωt) + (1/3)sin(3ωt) + (1/5)sin(5ωt) + …. The higher the order, the less it adds, yet these small terms are what make the edges steep. Even at high orders the plot keeps a small horn just beside each edge: adding terms makes the horn narrower but no lower. This is the Gibbs phenomenon.
Sinusoidal analysis extends to every periodic signal
This is where impedance and frequency response pay off. If you know how a linear circuit changes the size and phase of a sine at each frequency, you can split any input into harmonics, pass each one through, and add them back up to get the output. Feed a square wave into a filter that cuts high frequencies and its high harmonics shrink, rounding the edges; the shape you see when you lower the order in the plot looks much like that result. Handle one sine properly and, in effect, you can handle every periodic signal.
Back to the first screen
On the first button the thick line was a round sine; as odd harmonics were added one by one its top flattened, its edges steepened, and it closed in on the dashed square wave. The harmonics shrank as 1/n, yet every one of those small terms was needed to raise the edges. Because even a complicated-looking waveform is in the end a sum of sines, every tool for solving a circuit with one sine carries over to an arbitrary periodic signal.