The Strange Mathematics of Musical Tuning: Why Pianos Are Always a Little Wrong
The relationship between simple frequency ratios and a fixed-pitch keyboard is mathematically impossible to satisfy exactly. Three thousand years of music theory has been a sequence of compromises, each of which sounds wrong in some specific way that another compromise was designed to avoid.
The frequencies of a musical scale stand in simple ratios. An octave doubles the frequency, a perfect fifth multiplies by three over two, a perfect fourth by four over three, a major third by five over four. These ratios are not arbitrary — they are the ones the human ear hears as consonant because the harmonic series of one note overlaps cleanly with the harmonic series of another, producing reinforcement rather than beating. The Pythagoreans noticed this around 500 BCE and built a philosophical system on the observation. The mystical part has aged poorly. The mathematics is exactly correct.
The problem is that you cannot build a fixed-pitch keyboard that satisfies all these ratios simultaneously. The mathematics forbids it. Three thousand years of music theory have been a sequence of compromises, each addressing a specific failure of the previous compromise, and the modern equal-tempered piano is the current settlement — a system in which every interval except the octave is slightly out of tune, distributed so evenly across the twelve notes that no key sounds worse than any other. This is a remarkable engineering achievement and also slightly heartbreaking when you understand what was given up to get there.
The Pythagorean comma
The arithmetic that breaks the system is the comparison of two paths up the scale. Stack twelve perfect fifths starting from C — C to G to D to A to E to B to F# to C# to G# to D# to A# to E# to B#. After twelve fifths you arrive at a note that is enharmonically the same as C, seven octaves higher.
The frequency ratio of twelve perfect fifths is (3/2)^12 = 531441/4096 ≈ 129.746. The frequency ratio of seven octaves is 2^7 = 128. These are not equal. They differ by 531441/524288 ≈ 1.0136, a factor known as the Pythagorean comma — about a quarter of a semitone, large enough that the human ear can hear it.
This means twelve perfect fifths overshoot seven octaves by an audible amount. The twelfth fifth in the sequence does not return to the starting pitch class. There is no escape from this fact. It is a property of the rational numbers, not a defect in any particular tuning system.
What the early systems did about it
Pythagorean tuning, used in medieval Europe, distributed the comma onto a single fifth — usually G# to E♭ — and called that interval the "wolf fifth" because of the howling beats it produced. Music in keys that avoided the wolf was fine; music that needed to use it was unplayable. This was acceptable when most music stayed in a few keys close to C. It became unacceptable as composers wanted to modulate freely.
Just intonation, common in Renaissance vocal music, used pure ratios for the intervals within a single key but produced wrong intervals when you tried to modulate to a related key. The major third in C major (5/4) is not the same as the major third in G major would need to be, given that G itself is reached by a perfect fifth from C. Vocal ensembles can adjust on the fly because they have continuous pitch control. Keyboards cannot.
Meantone temperament, dominant from the late Renaissance through the 17th century, made the major third pure (5/4) and adjusted the fifths slightly flat to compensate. This worked beautifully in keys close to C and produced wolf intervals in remote keys. The wolf in quarter-comma meantone was about 35 cents wide of pure — much worse than equal temperament's deviations — and limited composers to roughly six usable keys.
Well temperament, the system Bach worked with for the Well-Tempered Clavier, distributed the comma unevenly across the twelve fifths in a way that made every key playable but gave each key its own characteristic flavor. C major sounded pure and noble; F# major sounded tense and exotic. The "tonal palette" arguments about key character that Romantic composers made about Beethoven were genuinely meaningful in well temperament and became nostalgic mythology after equal temperament won.
The equal temperament settlement
Equal temperament divides the octave into twelve equal logarithmic steps, each of frequency ratio 2^(1/12) ≈ 1.05946. Twelve such steps multiply to exactly 2 — the octave is preserved precisely. Every other interval is slightly off. The fifth becomes 2^(7/12) ≈ 1.4983 instead of 1.5 (about 2 cents flat). The major third becomes 2^(4/12) ≈ 1.2599 instead of 1.25 (about 14 cents sharp — a much larger error). The minor third is similarly compromised.
The mathematical elegance is that the comma is distributed evenly. No key is privileged; no key is unplayable. The price is that no interval except the octave is exactly in tune. The major third in equal temperament beats noticeably faster than a pure major third — sit at a piano and listen to a sustained C-E and you can hear the wobble.
The system was known mathematically since the 16th century — Vincenzo Galilei (Galileo's father) wrote about it in 1581 — but adoption took two centuries because instrument makers and players resisted the loss of pure thirds. The wide adoption of equal temperament for pianos came in the late 19th century, and it became universal only in the 20th. Some baroque-music revivalists still tune harpsichords to historical temperaments and insist that Bach's preludes and fugues were composed with specific key characters in mind that equal temperament obliterates.
Where the mathematics actually breaks
The deeper observation is that there is no choice of twelve frequencies that satisfies all the simple ratios of just intonation while being closed under transposition. This is not a limitation of human ears or the diatonic scale or Western tradition — it is a statement about the multiplicative structure of the rational numbers. Powers of 3/2 and powers of 2 generate disjoint subgroups of the multiplicative reals; you cannot cycle through one and land on the other.
Fixed-pitch keyboards force a discretization, and the discretization forces an approximation. Continuous-pitch instruments — voices, violins, trombones — escape the dilemma by being able to adjust each note in context. A string quartet playing in just intonation is mathematically possible because the players retune each note to fit the harmony of the moment. A piano in just intonation is possible only for one key at a time.
The Indian and Arab traditions, briefly
Other musical traditions made different settlements with the same arithmetic. Indian classical music uses 22 śruti — microtonal divisions of the octave — and modulates by selecting a different subset of seven for each rāga. The system is fundamentally just-intoned and its harmony stays within a single rāga at a time, which avoids the problem Western polyphony created for itself.
Arab classical music uses 24-tone equal temperament as a notational convenience over a more flexible practical tradition that treats specific pitches differently in different maqāmāt. The quarter-tone steps of the notation are not played as exactly equal intervals; they are approximations of the just intervals that the maqām calls for in context.
The pattern across traditions is that fixed-pitch instruments demand temperament, continuous-pitch traditions can avoid it, and which compromise to make is a function of what musical idioms you want to support.
Pure systems on modern hardware
Electronic instruments are not bound by the constraints of vibrating strings or resonant tubes. Software synthesizers can retune in real time based on the harmonic context of the moment, producing what is sometimes called "adaptive just intonation." The technique was pioneered by William Sethares and others in the 1990s and is occasionally used in microtonal compositions. Most listeners cannot tell the difference unless they are specifically prompted to listen for the absence of beating in held chords.
The fact that most listeners cannot tell suggests that the equal-temperament approximation is good enough for most musical purposes — that the gap between 14 cents sharp and pure is below the threshold of practical relevance for most music. The fact that some listeners can tell, and find equal-tempered chords subtly unsatisfying compared to pure ones, suggests that the gap is still real and that the achievement of equal temperament is a compromise rather than a solution.
Three thousand years of music theory has been the search for ways to live with the Pythagorean comma. The current settlement is a triumph of mathematical egalitarianism over acoustic purity. Whether that was the right tradeoff is a question musicians have argued about for two centuries and will probably argue about for several more.