Tuning Lab.

Why does a piano have 12 notes per octave? Because the irrational number log2(3/2) = 0.5849625… has a continued fraction whose convergents land on 2, 5, 12, 41, 53 — the equal divisions of the octave that best approximate a perfect fifth. Explore the number theory, then hear the difference between locked just intonation and drifting equal temperament.

The interval

Ratio3/2
f₁ (low)220.00
f₂ (high)330.00
Beating0.00 Hz
Just intonation closed & frozen — a stationary knot

The Lissajous figure plots the two tones against each other. When the frequency ratio is a simple integer (just intonation) the curve closes into a fixed knot and freezes. The 12-EDO fifth is 27/12, an irrational number just off 3/2, so its curve never closes — it slowly precesses.

Ear check: with a harmonic-rich tone, the just fifth's coincident partials (3f₁ = 2f₂) lock silently. In 12-EDO they miss by a hair and you hear slow beating at 0.75 Hz — the same number shown as “Beating” above. Toggle Just / 12-EDO while it plays.

Audio needs a click first (browser autoplay policy). Volume is capped.

Continued fraction → equal temperaments

Expand log2(3/2) as a continued fraction [0; 1, 1, 2, 2, 3, 1, 5, ...]. Its convergents p/q are the best rational approximations of a fifth-per-octave. The denominator q is an EDO; the best q-EDO fifth uses p steps (p = round(q·log2(3/2))). The just fifth is 701.955 cents.

Convergent p/qEDO (q)Fifth = p stepsFifth (cents) Error vs 3:2

12-EDO (7/12) is the sweet spot: only -1.955 cents off, with few enough notes to play. 53-EDO (31/53) is near-perfect (-0.068 c) but unwieldy. This is exactly why keyboards settled on 12.

Just intonation vs 12-EDO

cents = 1200·log2(ratio). Error = 12-EDO − JI. The current interval is highlighted.

IntervalJI ratioJI cents12-EDOError

Error, in cents

How far each 12-EDO note sits from its pure ratio. Bars right = sharp (amber), left = flat (coral). The major third (+13.7 c) is the famous offender.

The commas (exact)

Pythagorean comma = 312219 = 531441524288 ≈ 23.460 cents.

Stack 12 pure fifths (3/2) and you overshoot 7 octaves by this much — you cannot tile the octave with pure fifths, so a keyboard must compromise.

Syntonic comma = 8180 ≈ 21.506 cents.

Four pure fifths (up two octaves) vs one pure major third (5/4) differ by this. It is the gap meantone temperament spreads out to sweeten thirds.