Wave Functions

Add sine waves together, build square, sawtooth and triangle waves from their harmonics, and see how two close frequencies produce beats.

Intermediate
Presets:
-2-101200.511.52 s
  • Wave 1
  • Wave 2
  • Wave 3
  • Sum

1 sin(2π·1t + 0°)

0.5 sin(2π·2t + 0°)

0.33 sin(2π·3t + 0°)

Adding waves together

A sine wave y = A sin(2πft + φ) has three dials: amplitude A (how tall), frequency f (cycles per second) and phase φ (where in its cycle it starts). When two waves meet, their values simply add at every instant. This is the principle of superposition.

Waves of the same frequency that are in phase reinforce each other (constructive interference). Shift one by 180° and they cancel (destructive interference). Two waves with slightly different frequencies drift in and out of phase, so the loudness of their sum rises and falls: these are beats.

Fourier showed that the idea also runs backwards: any reasonable periodic signal can be written as a sum of sines at whole-number multiples of its base frequency. A square wave, for example, uses only the odd harmonics with amplitudes 1, 1/3, 1/5, ... Near a jump, a finite sum always overshoots by about 9% of the jump, however many terms you take. This is the Gibbs phenomenon.

Key formulas

A single sine wave

y(t) = A sin(2πft + φ)

A
amplitude
f
frequency in hertz; the period is T = 1/f
φ
phase, the starting angle

Beats (sum-to-product)

sin(2πf₁t) + sin(2πf₂t) = 2 cos(π(f₁ − f₂)t) · sin(π(f₁ + f₂)t)

|f₁ − f₂|
beat frequency: how many loud-quiet cycles per second

Fourier series (period 1)

square(t) = (4/π) Σk odd sin(2πkt) / k
sawtooth(t) = (2/π) Σk ≥ 1 (−1)k+1 sin(2πkt) / k
triangle(t) = (8/π²) Σk odd (−1)(k−1)/2 sin(2πkt) / k²

How to use this visualizer

  1. 1
    Compose waves: switch each wave on or off and set its amplitude, frequency and phase. The thick black curve is their sum. Try the Constructive and Destructive presets.
  2. 2
    Fourier series: pick a target shape and raise N. Watch the partial sum hug the dashed target more closely, and the spectrum fill in.
  3. 3
    Look at the corners of the square or sawtooth wave as N grows. The overshoot gets narrower, but the overshoot percentage stays near 9%.
  4. 4
    Beats: set f₁ and f₂ a little apart. The dashed envelope pulses at |f₁ − f₂| times per second; make them equal and the beating stops.

Where this shows up

Music and sound

An instrument note is a fundamental plus harmonics. Their relative strengths are what make a violin sound different from a flute.

Tuning by beats

Musicians tune by listening for beats between two strings and adjusting until the beating slows to zero.

Signal processing

Audio compression, equalisers and radio receivers all work on the frequency components of a signal.

Noise cancellation

Headphones play a copy of the noise shifted by 180°, so the two waves interfere destructively.

Practice problems

Problem 1: Beats from two tuning forks

Two tuning forks of 440 Hz and 444 Hz are struck together. How many beats per second are heard, and what pitch does the combined sound have?
Show solution

Beat frequency = |f₁ − f₂| = |440 − 444| = 4 Hz

The sum oscillates at the average frequency (f₁ + f₂)/2 = (440 + 444)/2 = 442 Hz

4 beats per second, heard at a pitch of 442 Hz

Problem 2: Square-wave harmonics

A square wave of amplitude 1 and frequency 50 Hz is built from its Fourier series. What are the frequencies and amplitudes of its first three non-zero harmonics?
Show solution

Only odd harmonics k = 1, 3, 5 appear, each with amplitude 4/(πk).

k = 1: 50 Hz, amplitude 4/π ≈ 1.273

k = 3: 150 Hz, amplitude 4/(3π) ≈ 0.424

k = 5: 250 Hz, amplitude 4/(5π) ≈ 0.255

50, 150 and 250 Hz with amplitudes 1.273, 0.424 and 0.255

Discussion

Questions, ideas or a different approach? Join the conversation.