Skip to content

The Mathematics of Music: Pythagoras, Harmony, and Equal Temperament

"There is geometry in the humming of the strings, there is music in the spacing of the spheres."
Pythagoras

Why do certain combinations of musical notes sound uplifting, triumphant, or sweet, while others sound tense, jarring, or harsh?

To our ears, music feels like an emotional art form. But beneath every chord, melody, and scale lies pure, unadulterated mathematics. Over 2,500 years ago, Greek philosophers discovered that the sensation of musical harmony is driven by simple integer ratios.

In this post, we will explore: 1. The Monochord Experiment: How Pythagoras discovered that pitch is geometry. 2. Consonance vs. Dissonance: Wave interference and the physics of acoustic beating. 3. The Harmonic Series: The universal staircase of overtones. 4. The Flaw in the Universe: The Pythagorean Comma and the Circle of Fifths. 5. The Modern Compromise: 12-Tone Equal Temperament (12-TET) and geometric ratios (\(r = \sqrt[12]{2}\)). 6. Interactive Harmony & Beating Laboratory: Listen to pure ratios vs. dissonant beating in real time!


1. The Monochord: Pitch is Geometry

Around 500 BCE, Pythagoras experimented with a monochord—a wooden soundbox with a single stretched vibrating string and a movable bridge. He observed a profound physical law: musical harmony is governed by small whole-number ratios of string lengths.

             Pythagorean String Length Ratios & Musical Intervals
                                                                          Frequency Ratio
Full String (1.0)       [═══════════════════════════════════] C4 (Fundamental)  1 : 1 (261.6 Hz)
Octave (1/2 length)     [═══════════════════]                 C5 (Double Pitch) 2 : 1 (523.2 Hz)
Perfect 5th (2/3 length)[═════════════════════════]           G4 (Fifth)        3 : 2 (392.0 Hz)
Perfect 4th (3/4 length)[═══════════════════════════════]     F4 (Fourth)       4 : 3 (348.8 Hz)
Major 3rd (4/5 length)  [═════════════════════════════════]   E4 (Major Third)  5 : 4 (327.0 Hz)
flowchart TD
    Pythagoras["Pluck Stretched String of Length L (Frequency f0)"]

    Pythagoras --> Half["Divide String in Half: L / 2"]
    Pythagoras --> TwoThird["Divide String at 2/3: 2L / 3"]
    Pythagoras --> ThreeFourth["Divide String at 3/4: 3L / 4"]
    Pythagoras --> FourFifth["Divide String at 4/5: 4L / 5"]

    Half --> Octave["Octave (2:1 Ratio)<br/>Identical note, higher register"]
    TwoThird --> Fifth["Perfect 5th (3:2 Ratio)<br/>Most powerful harmonic interval (C -> G)"]
    ThreeFourth --> Fourth["Perfect 4th (4:3 Ratio)<br/>Resonant foundational step (C -> F)"]
    FourFifth --> Third["Major 3rd (5:4 Ratio)<br/>Bright, cheerful chord tone (C -> E)"]

    style Pythagoras fill:#1e293b,stroke:#475569,stroke-width:2px,color:#fff
    style Octave fill:#2563eb,stroke:#1d4ed8,stroke-width:2px,color:#fff
    style Fifth fill:#10b981,stroke:#047857,stroke-width:2px,color:#fff
    style Fourth fill:#06b6d4,stroke:#0891b2,stroke-width:2px,color:#fff
    style Third fill:#f59e0b,stroke:#d97706,stroke-width:2px,color:#fff

When you pluck an open string, it vibrates at frequency \(f_0\). If you press your finger down at the exact midpoint (\(1/2\) length), the string vibrates twice as fast (\(2f_0\)). The human brain recognizes \(2f_0\) as the exact same musical note, just one octave higher.


2. Consonance vs. Dissonance: The Physics of Acoustic Beating

Why do simple ratios like \(2:1\), \(3:2\), and \(4:3\) sound pleasing (consonant), while complex ratios like \(45:32\) (the dreaded tritone or "devil's interval") sound tense and jarring (dissonant)?

The secret lies in wave interference and acoustic beating.

When two sound waves with frequencies \(f_1\) and \(f_2\) play simultaneously, their combined waveform is:

\[y(t) = \sin(2\pi f_1 t) + \sin(2\pi f_2 t) = \underbrace{2 \cos\left( 2\pi \frac{f_1 - f_2}{2} t \right)}_{\text{Pulsing Envelope}} \cdot \underbrace{\sin\left( 2\pi \frac{f_1 + f_2}{2} t \right)}_{\text{Carrier Pitch}}\]
                 Acoustic Beating Interference Pattern
       Peak-to-Peak (Loud)               Trough-to-Trough (Loud)
           ╭───╮                             ╭───╮
          ╭╯   ╰╮   Destructive (Quiet)     ╭╯   ╰╮
         ╭╯     ╰╮        ┌───┐            ╭╯     ╰╮
       ──╯       ╰────────╯   ╰────────────╯       ╰───
         │◄──────── Beat Period T_beat = 1 / |f1 - f2| ────────►│
  • Slow beating (\(1 - 5\text{ Hz}\)): The volume throbs gently (used by piano tuners to tune unisons).
  • Rapid beating (\(15 - 40\text{ Hz}\)): The ear cannot separate individual pulses, perceiving a harsh, grating friction. This is dissonance.
  • Harmonic alignment (Simple integer ratios): Overtones fall into exact matching frequencies (\(2f_1 = 3f_2\)). There is zero phase clash and no acoustic beating. This is consonance.

3. The Harmonic Series: Nature's Musical Staircase

When a physical string or acoustic air column vibrates, it doesn't vibrate at only one frequency. Boundary conditions force it to vibrate simultaneously in integer multiples called the Harmonic Series:

\[f_n = n \cdot f_0 \quad (n = 1, 2, 3, 4, 5, \dots)\]
        The First 6 Harmonics of Root Note C2 (65.4 Hz)

Harmonic   Frequency Multiple   Musical Note   Interval from Fundamental
  1st            1 f₀              C2          Fundamental Root
  2nd            2 f₀              C3          Octave (2:1)
  3rd            3 f₀              G3          Perfect 5th (3:2)
  4th            4 f₀              C4          Double Octave (4:1)
  5th            5 f₀              E4          Major 3rd (5:4)
  6th            6 f₀              G4          Octave + 5th (6:1)

Every time you hear a single note played on a cello, trumpet, or piano, your ear is secretly hearing the entire Major Triad chord (\(C - E - G\)) embedded within the physics of the harmonic series!


4. The Pythagorean Comma: A Mathematical Paradox

Pythagoras attempted to construct an entire 12-note musical scale by starting at a root note and repeatedly stacking Perfect Fifths (multiplying by \(3/2\)):

\[C \xrightarrow{\times 3/2} G \xrightarrow{\times 3/2} D \xrightarrow{\times 3/2} A \xrightarrow{\times 3/2} E \dots\]

After stacking 12 consecutive fifths, you should theoretically return to the exact same note (7 octaves higher):

graph LR
    C["C"] --> G["G"] --> D["D"] --> A["A"] --> E["E"] --> B["B"]
    B --> Fs["F#"] --> Cs["C#"] --> Gs["G#"] --> Ds["D#"] --> As["A#"] --> F["F"] --> CEnd["C (Cycle Closes?)"]

    style C fill:#1e40af,stroke:#3b82f6,stroke-width:2px,color:#fff
    style CEnd fill:#ef4444,stroke:#b91c1c,stroke-width:2px,color:#fff

Mathematically, 12 fifths must equal 7 octaves:

\[\left(\frac{3}{2}\right)^{12} \stackrel{?}{=} 2^7\]

Let us calculate the numbers:

\[\left(\frac{3}{2}\right)^{12} = \frac{531,441}{4,096} \approx 129.746338\]
\[2^7 = 128\]

They do not match!

\[\frac{129.746338}{128} \approx 1.013643 \quad (\text{a discrepancy of } \approx 23.46 \text{ musical cents})\]

This small fractional error is the Pythagorean Comma. Because no power of \(3\) can ever equal a power of \(2\) (\(3^{12} \ne 2^{19}\) by the Fundamental Theorem of Arithmetic), a purely integer-based musical scale can never close its circle perfectly.

For over a millennium, instruments tuned to pure fifths suffered from the infamous Wolf Fifth—a note so dissonant and out of tune that it sounded like the howling of a wolf.


5. The Solution: 12-Tone Equal Temperament (12-TET)

During the Renaissance, musicians and mathematicians realized that instead of making 11 intervals pure and leaving one horrible "wolf interval", they could distribute the Pythagorean Comma equally across all 12 semitones.

In 12-Tone Equal Temperament (12-TET), the frequency ratio between every adjacent semitone is geometrically identical:

\[r = \sqrt[12]{2} = 2^{1/12} \approx 1.059463094\]

The frequency \(f_n\) of any note \(n\) semitones above reference pitch \(A_4 = 440\text{ Hz}\) is:

\[f_n = 440 \times 2^{n/12}\]
Interval Pure Integer Ratio Pure Ratio Value 12-TET Equal Ratio (\(2^{n/12}\)) Difference (Cents)
Unison \(1 : 1\) \(1.0000\) \(2^{0/12} = 1.0000\) \(0.0\text{ ¢}\) (Exact)
Minor 3rd \(6 : 5\) \(1.2000\) \(2^{3/12} \approx 1.1892\) \(-15.6\text{ ¢}\) (Slightly flat)
Major 3rd \(5 : 4\) \(1.2500\) \(2^{4/12} \approx 1.2599\) \(+13.7\text{ ¢}\) (Slightly sharp)
Perfect 4th \(4 : 3\) \(1.3333\) \(2^{5/12} \approx 1.3348\) \(+2.0\text{ ¢}\) (Nearly perfect)
Tritone \(45 : 32\) \(1.4063\) \(2^{6/12} = \sqrt{2} \approx 1.4142\) \(+9.8\text{ ¢}\)
Perfect 5th \(3 : 2\) \(1.5000\) \(2^{7/12} \approx 1.4983\) \(-2.0\text{ ¢}\) (Practically imperceptible!)
Octave \(2 : 1\) \(2.0000\) \(2^{12/12} = 2.0000\) \(0.0\text{ ¢}\) (Exact)

Equal Temperament sacrificed mathematical perfection by making every Major 3rd slightly sharp by 14 cents, but it gave humanity a profound gift: the ability to play in all 12 musical keys without retuning the instrument.


6. Interactive Harmony & Acoustic Beating Laboratory

Use the interactive Web Audio playground below to listen to pure consonant ratios vs. dissonant beating frequencies and watch their interference waveforms in real time.

Interval: Perfect 5th (3:2)
Beat Frequency: 0.0 Hz
Second Tone: 660.0 Hz
Combined waveform superposition $y(t) = \sin(2\pi f_1 t) + \sin(2\pi f_2 t)$ Notice how slight frequency offsets create undulating beating envelopes!

7. What Comes Next?

Now that we understand how mathematical ratios construct harmony and scales: - How does an instrument produce its unique timbre (tone color)? - How do computers decompose complex musical chords into individual frequencies?

👉 Next in this Series: Continue to Deconstructing Sound: The Fourier Transform, Timbre, and Audio Processing to explore how the Fourier Transform acts as a mathematical prism for sound!