Home / Articles / Mathematics in Real Life
Mathematics in Real Life · 6 min read

The Mathematics of Music

Explore how ratios, frequencies, logarithms and fractions shape melody, harmony and rhythm, with worked examples on string vibrations and musical tuning.

Music feels like pure emotion, but underneath every melody lies a beautiful structure of numbers. The pitch of a note is a frequency, harmony comes from simple ratios, scales are built with exponents and logarithms, and rhythm is a lesson in fractions. Let us tune in to the mathematics that makes music sound the way it does.

Sound as a Wave

When a guitar string or a tabla skin vibrates, it pushes air molecules back and forth, creating a pressure wave. Two numbers describe this wave:

  • Frequency \( f \): the number of vibrations per second, measured in hertz (Hz). Higher frequency means higher pitch.
  • Amplitude: the size of the vibration. Larger amplitude means a louder sound.

Humans can hear roughly from 20 Hz to 20,000 Hz. By international agreement, the note A above middle C (called A4) is usually tuned to exactly 440 Hz.

Pythagoras and Harmonious Ratios

According to tradition, the Greek philosopher Pythagoras (around 570 to 495 BC) noticed that strings whose lengths were in simple whole-number ratios produced pleasant combinations of sounds. Whether or not the story about him is exact, the discovery is real:

  • Halving a string's length doubles its frequency, giving an octave (ratio 2:1).
  • Two-thirds of the length gives a perfect fifth (ratio 3:2).
  • Three-quarters of the length gives a perfect fourth (ratio 4:3).

Notes whose frequencies are in simple ratios sound smooth together because their wave patterns line up regularly. Complicated ratios produce "beating" that the ear hears as tension or dissonance.

The Physics of a Vibrating String

The frequency of a stretched string depends on its length \( L \), its tension \( T \) and its mass per unit length \( \mu \):

$$ f = \frac{1}{2L}\sqrt{\frac{T}{\mu}} $$

This one formula explains how every string instrument is played: pressing a finger on a fret shortens \( L \), tightening a tuning peg increases \( T \), and thicker bass strings have larger \( \mu \).

Worked Example 1: Frequency of a Guitar String

A guitar string has vibrating length 0.65 m, tension 70 N and mass per unit length 0.0005 kg/m. Find its frequency.

Step 1: Compute the wave speed on the string.

$$ v = \sqrt{\frac{T}{\mu}} = \sqrt{\frac{70}{0.0005}} = \sqrt{140000} \approx 374.2 \ \text{m/s} $$

Step 2: Divide by twice the length.

$$ f = \frac{374.2}{2 \times 0.65} = \frac{374.2}{1.3} \approx 287.8 \ \text{Hz} $$

Step 3: Interpret. This is a note a little below D4 (about 293.7 Hz). If the player presses the string at its midpoint, \( L \) halves to 0.325 m and the frequency doubles to about 575.6 Hz, exactly one octave higher.

Building a Scale: Equal Temperament

Western music divides the octave into 12 semitones. If each semitone multiplies the frequency by the same number \( r \), then twelve steps must double the frequency:

$$ r^{12} = 2 \quad\Rightarrow\quad r = 2^{1/12} \approx 1.05946 $$

This system is called twelve-tone equal temperament. The frequency of a note \( n \) semitones above A4 is

$$ f = 440 \times 2^{n/12} $$

with \( n \) negative for notes below A4.

Worked Example 2: Finding Middle C

Middle C (C4) is 9 semitones below A4. Find its frequency.

Step 1: Substitute \( n = -9 \).

$$ f = 440 \times 2^{-9/12} = 440 \times 2^{-0.75} $$

Step 2: Evaluate the power.

$$ 2^{-0.75} \approx 0.59460 $$

Step 3: Multiply.

$$ f \approx 440 \times 0.59460 \approx 261.6 \ \text{Hz} $$

Middle C is about 261.6 Hz, a value every piano tuner knows.

Why Equal Temperament Is a Compromise

In equal temperament a fifth is 7 semitones:

$$ 2^{7/12} \approx 1.4983 $$

which is very close to, but not exactly, the pure ratio 1.5. The tiny error is the price we pay for being able to play in every key on one instrument.

The reason a perfect system is impossible is a neat piece of number theory. Stacking twelve pure fifths should bring us back to the same note seven octaves higher, but

$$ \left(\tfrac{3}{2}\right)^{12} \approx 129.75 \quad\text{while}\quad 2^{7} = 128 $$

The leftover ratio, \( 129.75 / 128 \approx 1.0136 \), is called the Pythagorean comma. Since no power of 3 can equal a power of 2, pure fifths and pure octaves can never fit together perfectly. Equal temperament spreads that small error evenly over all twelve fifths.

Logarithms and Cents

Our ears hear pitch logarithmically: each octave sounds like the same "distance" even though the frequency doubles each time. Musicians therefore measure intervals in cents, where an octave is 1200 cents:

$$ \text{cents} = 1200 \log_2\left(\frac{f_2}{f_1}\right) $$

For a pure fifth, \( 1200 \log_2(1.5) \approx 702 \) cents, while the equal-tempered fifth is exactly 700 cents. Electronic tuners display this kind of value to show how sharp or flat a note is.

Loudness is logarithmic too. The decibel scale adds 10 dB each time sound intensity is multiplied by 10.

Rhythm: Fractions in Time

Rhythm is arithmetic with fractions. In a 4/4 time signature, each bar contains four quarter-note beats. A whole note lasts 4 beats, a half note 2, a quarter note 1, an eighth note \( \tfrac{1}{2} \) and a sixteenth note \( \tfrac{1}{4} \). A composer must make every bar add up correctly, for example

$$ \tfrac{1}{2} + \tfrac{1}{4} + \tfrac{1}{8} + \tfrac{1}{8} = 1 \ \text{(a full bar of 4/4 in whole-note units)} $$

South Asian classical music has its own rich rhythmic mathematics. A taal is a repeating cycle of beats: teentaal has 16 beats grouped 4 + 4 + 4 + 4, jhaptaal has 10 grouped 2 + 3 + 2 + 3, and rupak has 7 grouped 3 + 2 + 2. Tabla players create tihais, phrases repeated three times so that they end exactly on the first beat (sam) of the cycle, which is really a puzzle in modular arithmetic.

Overtones and Timbre

Why does the same note sound different on a sitar and a flute? A vibrating string does not vibrate at just one frequency. It also vibrates at whole-number multiples called harmonics: \( f, 2f, 3f, 4f, \dots \). The mix of these harmonics gives each instrument its timbre. Mathematically, any repeating sound wave can be broken into a sum of sine waves, a result known as Fourier analysis, which is also how music apps compress songs into MP3 files.

Did You Know?

  • The frequencies of the harmonics of a note \( f, 2f, 3f, 4f \) produce the octave, the fifth and the fourth as ratios between neighbouring harmonics: \( 2:1, 3:2, 4:3 \).
  • Johann Sebastian Bach's The Well-Tempered Clavier (1722) was written to show off music in all 24 major and minor keys on a keyboard tuned so that every key was usable.
  • The A4 = 440 Hz standard was widely agreed at an international conference in London in 1939; before that, orchestras tuned to many different pitches.

Key Takeaways

  • Pitch is frequency, and pleasant intervals come from simple ratios such as 2:1 and 3:2.
  • A string's frequency is \( f = \frac{1}{2L}\sqrt{T/\mu} \), explaining frets, tuning pegs and string thickness.
  • Equal temperament uses the ratio \( 2^{1/12} \) per semitone, giving \( f = 440 \times 2^{n/12} \).
  • Pitch and loudness are perceived logarithmically, measured in cents and decibels.
  • Rhythm, including the taals of South Asian music, is built on fractions and cycles.

If logarithms, exponents or wave physics questions are giving you trouble, Amathify's subject experts and PhD scholars can provide step-by-step solutions and assignment help; contact us on WhatsApp or through the Ask a Question form.

Stuck on a problem or assignment?

Our experts and PhD scholars solve maths, physics and chemistry — step by step.

WhatsApp usAsk a question

Related articles