SimuVeda

Mathematics · Simulator 043

Fourier Synthesis

Add sine waves together, one harmonic at a time, and watch a square, sawtooth or triangle wave emerge. Set your own harmonic amplitudes, compare the waveform with its frequency spectrum, and find the stubborn overshoot at sharp jumps.

How the model works

Any reasonable periodic signal can be written as a sum of sines and cosines at whole-number multiples of its fundamental frequency (a Fourier series):

f(t) = Σₙ bₙ sin(2π n t / T)

  • Square wave: odd harmonics only, bₙ = 4/(nπ). Amplitudes fall slowly as 1/n.
  • Sawtooth: all harmonics, bₙ = 2(−1)ⁿ⁺¹/(nπ).
  • Triangle: odd harmonics with alternating sign, bₙ = 8(−1)^((n−1)/2)/(n²π²). They fall fast as 1/n², because the wave has no jumps, only corners.

The smoother the wave, the faster its harmonics shrink. At a jump, partial sums always overshoot by about 9% of the jump, however many terms you add. This is the Gibbs phenomenon: the overshoot gets narrower but not shorter.

The spectrum chart shows |bₙ| for each harmonic (a line spectrum). In audio, these harmonics are what make a note sound like a flute (few harmonics) or a buzzy synthesiser (many).

Sine-only (odd-symmetric) series; the custom mode lets you set the first eight amplitudes. No sound is played.

Guided experiments

  1. Build a square wave. Increase harmonics from 1 to 25. Prediction: the sum flattens and sharpens. With 1 term it is a pure sine of height 4/π ≈ 1.27.
  2. Gibbs overshoot. Square wave with 99 harmonics. Prediction: the peak near the jump stays at about 1.18 (9% of the 2-unit jump above 1), not 1.0.
  3. Triangle converges faster. Triangle with 5 harmonics. Prediction: already almost perfect. The maximum error is about 3% of the peak, versus visible ripples for a square wave with the same count.

Challenge

A square wave and a triangle wave both have the fundamental amplitude b₁ at n = 1. How much weaker is the 9th harmonic than the fundamental in each?

Reveal the explanation

Square: bₙ ∝ 1/n, so the 9th is 1/9 ≈ 11% of the fundamental. Triangle: bₙ ∝ 1/n², so 1/81 ≈ 1.2%. That is why a triangle wave sounds much softer and purer than a square wave at the same pitch.

References

  • OpenStax, Calculus Volume 3 (series) and MIT OpenCourseWare 18.03, “Fourier series”.
  • Gibbs, J. W. (1899), letter in Nature 59: 606.