If you stretch a string between two points, pluck it, and listen, you hear a tone. Now stop the string at the exact midpoint with your finger and pluck either half. The tone you hear is the same note, an octave higher — pleasing, consonant, identifiable. Stop it at the two-thirds point and the new tone forms what musicians call a perfect fifth — also consonant. Three-quarters: a perfect fourth. Four-fifths: a major third.

This observation, which the Pythagorean school of ancient Greece made some 2500 years ago, was one of the first and most consequential discoveries in mathematics. It didn’t merely describe a natural phenomenon — it suggested that the universe might, in some deep sense, run on integer ratios. The Pythagoreans built a whole philosophy on this idea, much of it mystical and later proved wrong, but the empirical observation was correct: musical pleasure correlates with simple integer relationships between frequencies.

This article is about how that ancient insight became modern equal-temperament tuning, why the journey was so much harder than it looked, and what role pure mathematics played in shaping the music you’ve been listening to your entire life.

The integer ratios

A vibrating string with frequency ff produces a tone. Stop the string at half its length and the new frequency is 2f2f — an octave up. The ratio 2:12:1 is the octave.

Stop the string at 2/3 of its length and you get a frequency of 3f/23f/2 — a perfect fifth above the original. The ratio 3:23:2.

Stop at 3/4 of the length: frequency 4f/34f/3, a perfect fourth. Ratio 4:34:3.

These are the consonances. They were known to Pythagoras and his school in the 6th century BCE. The school had a slogan that has come down to us as “music is a hidden arithmetic exercise of the soul, which does not know that it is counting.” That overstates it — the soul’s accounting is a metaphor — but the underlying point is solid: the brain’s perception of musical consonance correlates strongly with simple integer ratios.

Why? The physical reason involves the harmonic series: a vibrating string doesn’t produce just one frequency but a whole series of overtones at integer multiples of the fundamental. The string’s ff, 2f2f, 3f3f, 4f4f, 5f5f all sound simultaneously. When two notes share many overtones, they sound consonant. The 3:2 ratio shares overtones at every multiple of 6f, every multiple of 12f, and so on — a dense overlap. Notes related by ugly ratios share few overtones and sound dissonant.

The Pythagorean problem

Now try to build a scale by stacking perfect fifths. Start at C; go up a fifth to G; up another fifth to D (an octave higher); back down to D; up another fifth to A. Continue. After twelve fifths, you should arrive back at C — seven octaves up.

But you don’t, exactly. Twelve perfect fifths give a frequency ratio of (3/2)12129.7(3/2)^{12} \approx 129.7. Seven octaves give 27=1282^7 = 128. The discrepancy is

(3/2)1227=531,441524,2881.0136.\frac{(3/2)^{12}}{2^7} = \frac{531{,}441}{524{,}288} \approx 1.0136.

Twelve fifths overshoot seven octaves by about 1.4%. This tiny gap — about a quarter of a semitone — is called the Pythagorean comma, and it has been the central problem of music theory for 2500 years.

It is, mathematically, a deep statement about powers of small integers. The relation (3/2)a=2b(3/2)^a = 2^b has no positive integer solutions. There is no way to stack perfect fifths to land exactly on a power-of-two octave. The two prime factors 2 and 3 are incommensurable in this sense. You cannot escape the comma; you can only redistribute it.

Just intonation and its problems

The first attempt at building a usable scale was just intonation: use exact integer ratios for each interval relative to a fixed root. So C–E is exactly 5:4 (the major third), C–G is exactly 3:2 (the fifth), C–c is exactly 2:1 (the octave), and so on.

The problem: just intonation only works in the key it’s tuned to. If you tune your harpsichord to perfect ratios in C major, then try to play in G major, the intervals are no longer right — some of them are dramatically off. Modulation (changing key mid-piece) becomes impossible without retuning.

For most of history this didn’t matter. Greek and medieval European music was modal, written within a single tonal center. Composers stayed in one key. Just intonation worked.

But by the 1500s and 1600s, European composers — including the early Bach generation — wanted to modulate. To play in C, then E-flat, then F-sharp minor, all in the same piece, on the same instrument, you cannot use just intonation. Something has to give.

The compromise

A long sequence of intermediate solutions appeared between 1500 and 1700: mean-tone temperament, well temperament, the various circulating temperaments documented in tuning manuals of the period. Each made specific compromises: keep certain intervals pure, accept impurity in others, distribute the comma unevenly across the twelve fifths.

The breakthrough — and what most modern instruments use today — is equal temperament. Divide the octave into twelve equal parts on a logarithmic scale. Each semitone is a frequency ratio of 21/121.05952^{1/12} \approx 1.0595. The seventh step (the equal-tempered “fifth”) is 27/121.49832^{7/12} \approx 1.4983, very close to but not exactly 3/2.

The mathematics of equal temperament is a beautiful application of irrational numbers and approximation theory. The ratio 27/122^{7/12} is irrational. It cannot equal 3/2 exactly. It can, however, be remarkably close — within 0.1% — and this is what makes 12-tone equal temperament practical.

The same approximation question is, in a different form, why 12 turned out to be the right number of divisions of the octave. Continued fractions help here: the convergents of log2(3/2)0.585\log_2(3/2) \approx 0.585 are 1/2,3/5,7/12,24/41,31/53,1/2, 3/5, 7/12, 24/41, 31/53, \ldots The fraction 7/127/12 is the small denominator that gives a strikingly good approximation. This is why 12 notes per octave are standard, and why some traditions (including the historical Chinese system) experimented with 53-note scales — the next convergent. (For the math behind these convergents, see our continued fractions piece.)

Why equal temperament won

Equal temperament was theoretically described in the early 1500s but didn’t become standard until the late 1800s. Bach’s Well-Tempered Clavier (1722) used a circulating temperament, not pure equal temperament — different keys had slightly different characters because of the unequal distribution of the comma.

The change came partly from instrument-design pressure. Pianos with fixed tuning serve all keys equally; equal temperament minimizes the worst-case dissonance. Wind instruments with valves and key signatures had similar pressures. By the time of Brahms, equal temperament was nearly universal in European concert music.

Today, equal temperament is the default for nearly all Western music. Most listeners can’t distinguish it from just intonation in casual listening. Trained ears can hear the slight beating of equal-tempered intervals — particularly the major third, which is noticeably impure (about 0.8% off the just ratio of 5:4). But the trade-off — total modulation freedom for slight everywhere-impurity — is one nearly all musicians have accepted.

The continuing role of mathematics

Music’s relationship to mathematics didn’t end with the resolution of the temperament debates. Several modern threads:

Fourier analysis. Joseph Fourier’s 1822 result — that any periodic function can be decomposed into a sum of sines and cosines — is the mathematical foundation of all modern audio technology. Every digital filter, every audio synthesizer, every MP3 codec depends on Fourier analysis. Read our piece on the Fourier transform for the math.

Microtonal music. Composers like Harry Partch, Wendy Carlos, and many living musicians have explored scales with more or fewer than 12 notes per octave. 19-tone, 31-tone, 41-tone, and 53-tone equal temperaments all have devotees. The mathematics — choosing the number of divisions, computing the resulting interval qualities — is identical to the 12-tone case but with different convergents.

Algorithmic composition. Markov chains, fractal sequences, and chaotic dynamical systems have all been used to generate music. Iannis Xenakis composed pieces from stochastic processes in the 1950s; the tradition continues today in algorithmic and AI-generated music.

Tuning of physical instruments. The harmonic content of pianos, violins, and especially gamelan instruments deviates from pure integer ratios in subtle ways. Modern acoustical analysis reveals the actual harmonic content of real instruments is often not exactly f,2f,3f,f, 2f, 3f, \ldots — it has slight inharmonicity. Tuners adjust for this empirically (the “stretched octave” of piano tuning is a famous example).

What this all teaches

The story of musical tuning is a textbook case of mathematics encountering physical reality and being forced to compromise. Pure integer ratios are aesthetically perfect but practically impossible to combine consistently. Equal temperament is mathematically less elegant — irrational ratios, slight everywhere-impurity — but it solves the practical problem of modulation in a single self-consistent system.

The deeper observation is that the gap between mathematical perfection and practical workability is a recurring theme. Something analogous happens in the calendar (no integer number of days in a year — see our continued fractions discussion), in physical engineering (no exact integer relationships in real metals), in cosmology (the universe’s fundamental constants don’t form clean ratios). Mathematics gives us pure structure; the world forces us to take pleasing approximations.

For musicians, that compromise is at the heart of the art form. Every piece of Western music since about 1900 has been built from twelve notes per octave, each spaced by an irrational ratio, all of them slightly off from the simple fractions that originally motivated the system. The result has been Beethoven, Stravinsky, Coltrane, Radiohead — all of them depending on a tuning system that the Pythagoreans would have considered a betrayal of the cosmic order.

But the cosmic order, it turned out, included irrational numbers from the start. Pythagoras was right that music is a kind of arithmetic. He just had not yet realized — and arguably never accepted — that the arithmetic in question went beyond integers.

That’s a lesson about mathematics, and about music, that 2500 years has not exhausted.

Frequently asked

Why are there exactly 12 notes in an octave?

Because of a near-coincidence in number theory: 2^(7/12) ≈ 1.498, very close to 3/2 (the perfect fifth). With 12 equal divisions of the octave, the seventh step approximates the natural perfect fifth almost exactly. Other divisions (5, 7, 19, 53) also work; 12 is a sweet spot of approximation quality and practical instrument design.

Did Pythagoras really discover music ratios?

Probably not personally — the discoveries are usually attributed to the Pythagorean school as a whole, over generations. But the basic insight that musical intervals correspond to small integer ratios (2:1 for octave, 3:2 for fifth, 4:3 for fourth) is genuinely ancient and is one of the earliest known connections between mathematics and a physical phenomenon.

Why does the equal-tempered system sound slightly 'off'?

Because it deliberately accepts small imperfections in every interval to make modulation between keys possible. A pure perfect fifth is exactly 3:2 (a frequency ratio of 1.500); the equal-tempered fifth is 2^(7/12) ≈ 1.4983. The 0.1% difference is detectable to trained ears but most listeners adapt to it as the modern norm.