What's a square wave made of?

Explore · 10 min

Here's one of the most useful facts in electronics: every repeating waveform, whatever its shape, is a sum of sine waves. One at the waveform's own frequency, the fundamental, plus others at exactly 2, 3, 4… times it, its harmonics. Only their sizes (and which way up they are) change from shape to shape.

A chord on a piano is the same idea: one note's sound is its fundamental plus its harmonics, and their mix is why a piano and a violin playing the same note sound different.

So let's build a square wave. The fundamental is set. Add harmonics until the sum matches the dashed square.

A square wave at 1 kHz. Which frequencies is it made of?

  • 1 kHz only
  • 1, 2, 3, 4, 5 kHz…, each half the last
  • 1, 3, 5, 7 kHz…, with sizes 1, ⅓, ⅕, ⅐…
  • 1, 3, 5, 7 kHz…, all the same size

Now a triangle. It's a much smoother shape, so it shouldn't need as much at high frequencies. Match it:

Why do a triangle's harmonics fall so much faster than a square's?

  • A triangle has no sharp jumps, only corners, so it needs less of the fast sines that make sudden changes
  • A triangle has a lower frequency
  • A triangle wave has more energy

Every repeating waveform is a sum of sines:

ShapeHarmonicsTheir sizes
sinenone
squareodd only1/n
triangleodd only1/n2, alternating
sawtoothall1/n

This is Fourier's idea, and it's why frequency response matters so much: if you know what a circuit does to each sine, you know what it does to any waveform. Next lesson: seeing a signal's harmonics directly, on the scope's spectrum view.