explonio.All demosČesky

Mathematics

Fourier series

Add harmonics together, watch them build a square, sawtooth or triangle wave, and draw a signal of your own.

Launch simulation

How it works

Any periodic signal can be written as a sum of sine waves whose frequencies are whole multiples of the fundamental frequency f₀. A square wave contains only odd harmonics with amplitudes 4/(πn), that is 1.27, 0.42, 0.25, 0.18 …; a sawtooth has all harmonics with amplitudes proportional to 1/n, and a triangle wave has odd harmonics falling as 1/n². The more harmonics you add, the sharper the edges. At a jump, however, an overshoot of about 9 % of the jump remains – the Gibbs phenomenon.

x(t) = c₀ + Σ Aₙ · sin(2πn·f₀·t + φₙ)square wave: Aₙ = 4/(πn) for odd n

Try it yourself

  1. Choose “Square wave” and click “Build a square wave”. Harmonics are added one by one: the first is a sine wave with amplitude 1.27, the third adds 0.42.
  2. Raise “Highest order N” from 7 up to 32. The edges get sharper, but the overshoot at the jump only narrows; it does not disappear.
  3. Click “Same spectrum, different shape”. Changing the phase of the third harmonic changes the shape of the signal, although the amplitude spectrum stays the same.
  4. Choose “Custom signal” and draw one period. The demo breaks it into up to 32 harmonics and a DC offset; with sound enabled you can hear how it sounds.

Model limitations

The sum contains at most 32 harmonics, so jumps are never perfectly sharp. A drawn signal is sampled at 256 points. The sound leaves out the DC offset and components beyond what the device can play, and its volume is limited to prevent clipping; it is not a calibrated measurement.

Related experiments