📘 CodingMarble Learn

Mathematics in Music

A sound is a wave. Its frequency f (in hertz) is the pitch, and its period is T = 1 / f. Strings of length ratio 1 : 2 sound an octave apart, 2 : 3 a fifth. A piano octave has 12 equal steps, each a factor of 2^(1/12) = 1.0595. Rhythm splits a bar into fractions, for example 3 + 3 + 2 = 8 beats.

🎬 Step-by-step story

  1. A string wiggles 220 times a second. We slow it down so you can see it. That count is its frequency, and it is the pitch you hear.
  2. Cut the string to half the length. It now wiggles twice as fast, 440 a second. Ratio 1 : 2, one octave higher.
  3. Two-thirds of the length gives 330. The ratio of the two pitches is 2 : 3, called a fifth. Small whole-number ratios sound pleasant.
  4. A piano octave has 12 steps. Each key is the one before it times 1.0595. After 12 steps the pitch has doubled. Tap a key to hear it.
  5. Rhythm is also maths. A bar of 8 beats can be split 3 + 3 + 2. Press the beat button and count.
  6. Free play: slide the length of string 2. Watch the pitch and the ratio change, and press play to hear it.

Tip: drag the 3D scene to turn it. Use two fingers to zoom.

🤔 Common doubts, cleared

Why can we not see the string vibrate at 220 times a second?

It is too fast for our eyes. The 3D slows it down but keeps the same relative speed, so you can compare strings.

Why does half the length give an octave?

Half the length means twice the wiggles in each second. Twice the frequency is the ratio 2 : 1, an octave. Compare the two strings in the 3D.

Why do some ratios sound nicer?

In a simple ratio like 2 : 3, the two waves meet again after only 2 and 3 cycles, so the sound is steady. In a complicated ratio they take very long to match.

Why is each piano key multiplied, not added?

Our ears notice ratios. Going up the same number of semitones always multiplies the frequency by the same factor, so the steps in Hz grow as you go up. Tap keys 0 and 12 to see the doubling.

What is the maths of rhythm?

Adding fractions. 3 + 3 + 2 beats make 8 beats, and 3/8 + 3/8 + 2/8 = 1 whole bar.

How do I find the note for any string length?

Use f = 220 ÷ L (L as a fraction of the long string). Slide the string and read the Hz in the readout.

Sound waves

Sound is a vibration that travels as a wave. The frequency f is how many vibrations happen in one second. It is measured in hertz (Hz). The period T is the time for one vibration, so T = 1 / f. A string that vibrates 220 times a second has f = 220 Hz and T = 1/220 s.

A higher frequency sounds like a higher pitch. A bigger swing (amplitude) sounds louder. The wave moves through air at about 343 m/s, and its wavelength is λ = v / f.

For a string with the same thickness and tension, the frequency is inversely proportional to its length: f ∝ 1 / L. Half the length gives twice the frequency.

Intervals are ratios

The jump between two notes is an interval. Its size is the ratio of the two frequencies, not their difference.

Two waves in a simple ratio meet again very often, so together they sound smooth. This is why simple ratios feel harmonious.

Scales and temperaments

A scale is a set of notes inside an octave. Old Greek tuners built one by stacking fifths (multiplying by 3/2 and bringing the note back into one octave by halving). This is the Pythagorean way. But twelve perfect fifths do not fit exactly into seven octaves: (3/2)12 = 129.75, while 27 = 128. The tiny gap, a ratio of about 1.0136, is the Pythagorean comma.

To avoid that gap, most pianos use equal temperament: the octave is split into 12 equal steps, each step a factor of 21/12 ≈ 1.05946. So the note n semitones above a base note of frequency f₀ has frequency f₀ × 2n/12. After 12 steps the factor is 2, an octave. A seventh step (a fifth) gives 27/12 = 1.4983, very close to the pure 1.5.

Indian music uses 22 small steps called shruti and sets notes by ratios from Sa, so the ear can sit on the pure Sa-Pa ratio of 3 : 2. Other systems pick other compromises. That is what "temperament" means.

Rhythm

Rhythm is time cut into equal beats. A bar (or avartan in Indian music) is a group of beats. Note lengths are fractions: a whole note is 1, a half is 1/2, a quarter is 1/4, an eighth is 1/8. In 4/4 time, four quarter notes (4 × 1/4 = 1) fill one bar.

The tempo is in beats per minute (BPM). Time for one beat = 60 ÷ BPM seconds. At 120 BPM one beat lasts 0.5 s.

Beats can be grouped unevenly: 3 + 3 + 2 = 8 (seen in many folk styles), or 3 + 2 + 2 = 7 as in the Indian Rupak tala. The groups always add up to the length of the bar.

Try it: rubber band and bottles

Stretch a rubber band over a box and pluck it. Press it in the middle to make half the length: the note goes up by an octave. Or fill 5 identical bottles with different water levels and blow across them. Predict the order of the pitches, then check. Clap a 3 + 3 + 2 rhythm with a friend.

Key formulas and definitions

Worked examples

1. A string takes 0.004 s for one vibration. Find its frequency.

f = 1 / T = 1 / 0.004 = 250 Hz.

2. Find the wavelength in air of a 440 Hz note (speed 343 m/s).

λ = v / f = 343 / 440 ≈ 0.78 m.

3. A string of length 60 cm sounds 330 Hz. It is shortened to 45 cm. What is the new frequency?

f ∝ 1 / L. New f = 330 × 60 / 45 = 440 Hz.

4. Using equal temperament, find the note 7 semitones above 220 Hz. Compare with the pure fifth.

f = 220 × 2^(7/12) = 220 × 1.4983 ≈ 329.6 Hz. The pure fifth gives 220 × 3/2 = 330 Hz. The difference is under 0.5 Hz.

5. A song is at 90 BPM in 4/4 time. How long is one bar?

One beat = 60 / 90 = 2/3 s. A bar has 4 beats, so 4 × 2/3 = 2.67 s.

6. Show that twelve perfect fifths overshoot seven octaves.

(3/2)^12 = 129.746. Seven octaves is 2^7 = 128. The ratio 129.746 / 128 ≈ 1.0136, a gap of about 1.4% (the Pythagorean comma).

Common mistakes

Practice quiz

1. The unit of frequency is:
2. A string is cut to half its length. Its frequency becomes:
3. The frequency ratio of a fifth is:
4. In equal temperament one semitone multiplies the frequency by about:
5. At 60 BPM one beat lasts:

Practice: answer these yourself

Type or choose your answer, then press Check. Use a hint if you are stuck; the full solution appears after you answer.

Frequently asked questions

Why does a shorter string sound higher?

A shorter string vibrates faster, so its frequency is higher. Half the length makes the frequency double.

What is 2^(1/12)?

It is the 12th root of 2, about 1.05946. Multiply any note by it 12 times and you get exactly double, an octave.

Where is this topic taught?

It is an elective on maths in music and art, for example in senior school maths in China (Mathematics in music). The same ideas appear in physics (sound waves) and music courses.

Where this is taught

FrancePremièreSound and music
China八年级(初二)Ch.23 Linear functions
China高三Elective D (PE and arts)

Learn first

Learn next

Related lessons

All Maths lessons