How can sine waves add up to make a square wave?

Add a sine at the note's pitch, then sines at three, five, seven, and more times the pitch, each one quieter in proportion. The bumps cancel in the middle and pile up at the edges until the sum looks square. Every repeating sound can be built this way, which is how synthesizers and your ear make sense of timbre.

2 sines toward a sawtooth wave: every harmonic, each 1/n as loudsumdashed: the ideal wave12harmonic strengths
Highest harmonic used
2
Overshoot at the jumps
0%
Peak of the sum (ideal is 1)
×0.827

Challenge: Add 30 or more sines to a square wave and see that the overshoot never drops below 8%.

More settings

Play

Start at 1 sine and slide up. Press "Add them one at a time" to hear the tone get brighter.

Challenge: Add 30 or more sines to a square wave and see that the overshoot never drops below 8%. The box under the picture turns green when you get it.

Stuck? Pick one of the examples from the “Try an example” menu, or press “New example.”

Understand

x(t)=4π∑n=1,3,5,…5sin⁡(nωt)nx(t) = \frac{4}{\pi}\sum_{n=1,3,5,\ldots}^{5} \frac{\sin(n\omega t)}{n}

Any repeating wave can be written as a sum of sines at whole-number multiples of its pitch, a Fourier series. For a square wave the recipe is the odd harmonics, each 1/n1/n as strong:

x(t)=4π(sin⁡ωt+sin⁡3ωt3+sin⁡5ωt5+⋯ )x(t) = \frac{4}{\pi}\left(\sin\omega t + \frac{\sin 3\omega t}{3} + \frac{\sin 5\omega t}{5} + \cdots\right)

The top graph shows the sum against the ideal wave. The bars show each harmonic's strength, the same picture a spectrum analyzer draws. Try the sawtooth (every harmonic) and the triangle (odd ones, fading as 1/n21/n^2) to see how the recipe sets the shape and the sound.

Use

Every input has a unit menu, so you can type values in the units you already have. Results follow your units.

Show the work

  1. The recipe for a sawtooth wave: every harmonic, each 1/n as loudx(t) = \frac{2}{\pi}\sum_{n=1}^{2} (-1)^{n+1}\frac{\sin(n\omega t)}{n}
  2. The first few terms0.637\sin(1\omega t) - 0.318\sin(2\omega t)
  3. With a pitch of 220 Hz, the highest sine is2 \times 220 = 440\ \text{Hz}

Export

Export PDF

Pick a target shape and slide the number of sines. The sound buttons play your sum, build it up one stage at a time, and compare it with the ideal wave.

  • Synthesizer oscillators are band-limited: they stop below the top of hearing to avoid aliasing, so they are also finite sums like this.

For learning and estimation. Verify with applicable codes, standards, and a qualified professional before using in design, construction, or safety-critical work.

Cheat card

square=4π∑n oddsin⁡nωtn\text{square} = \frac{4}{\pi}\sum_{n\ \text{odd}}\frac{\sin n\omega t}{n}
sawtooth=2π∑n(−1)n+1sin⁡nωtn\text{sawtooth} = \frac{2}{\pi}\sum_{n}(-1)^{n+1}\frac{\sin n\omega t}{n}
triangle=8π2∑n odd±sin⁡nωtn2\text{triangle} = \frac{8}{\pi^2}\sum_{n\ \text{odd}}\pm\frac{\sin n\omega t}{n^2}
SymbolMeaningUnit
nnharmonic number
ω\omegaangular frequency, 2π × pitchrad/s
  • Odd harmonics only gives the hollow sound of a clarinet or a square-wave synth.
  • A 1/n² falloff fades the high harmonics fast, which is why a triangle wave sounds soft.
  • The sharper the corners in a wave, the more high harmonics it needs, and the brighter it sounds.

Print this card

Where it’s used

  • Music & Sound
    Additive synthesizers and organ drawbars build tones by mixing harmonics at chosen strengths.
  • Electrical & Electronics
    Engineers use Fourier series to see which frequencies a digital clock signal will radiate.
  • Music
    A clarinet sounds hollow because its tube favors odd harmonics, like a square wave.

Questions people ask

Why does a square wave need odd harmonics only?

A square wave looks the same flipped upside down half a period later. Even harmonics would break that symmetry, so their amounts come out to zero.

What is the Gibbs ripple?

Right next to each jump, the sum overshoots by about 9% of the jump. Adding more sines squeezes the ripple closer to the jump but never shrinks its height.

Is this how real instruments work?

Every steady musical tone is a sum of harmonics, and the mix of strengths is its timbre. Real instruments also change the mix over time, especially at the start of a note.

Updated : First published.

See everything that’s new on Maps for Math