Introduction
Pythagorus devised a musical system that relied on a couple simple principles. Using two ratios, he constructed the predecessor to what we, in the Western musical tradition, refer to as the major scale. For centuries, many instruments in the West were built according to this Pythagorean tuning system and its derivatives. The basic principles he laid out can still tell us a lot about how we relate to, compose, and understand music.
As we go through this material, keep in mind that the musical principles Pythagorus devised mark the beginning of only one musical history. There are many other musical systems that emerged in other parts of the world, each with its own history and musical theory. Later, we’ll explore some of those other musical systems to see how they compare to the Pythagorean system.
What sounds good to us?
Have you ever considered why some sounds are pleasing and others grating? Or why some chords sound sad while others sound happy? On the one hand, it might seems like these perceptions are matters of cultural inheritance. We associate minor keys with sad lyrics or emotionally heavy scenes in movies and shows, while we associate major keys with more joyful lyrics and scenes. But it’s worth asking whether these associations are entirely cultural in nature. Are there any universal musical experiences? If so, how might we use mathematics to explain that experience?
While cultural conditioning certainly plays a profound role in how we experience music, a mathematical investigation of music might also provide some insight into why we hear things the way we do. The Western (European) musical tradition is, for the most part, centered around the idea of the major scale - a set of seven notes. Most of the popular music we’ve ever heard is made of up just seven notes. The roots of this special set of notes can be traced back to Pythagorus.
Of course with all of these types historical narratives, it’s important to note that Pythagorus likely wasn’t the first to actually do this. Even the famous Pythagorean Theorem ($a^2 + b^2 = c^2$) has been discovered in Babylonian and Chinese texts that predate Pythagorus by centuries or more.
The Pythagorean Scale
In the sixth century BCE, Pythagorus discovered a remarkably simple way to generate pleasing sounds: First, take two strings of equal thickness and place them under equal tension. If the ratio of the lengths of the two strings can be expressed with small integer values, the sound that results when the two are played together will be pleasing to the ear. For example, if the strings are of lengths 40 cm and 20 cm, the ratio is $2:1$. If the strings are of lengths 30 cm and 20 cm, the ratio is $3:2$. In both cases, we’ll get a very pleasing sound if we play the strings simultaneously. These two ratios form the basis for the Pythagorean scale - $2:1$ and $3:2$.
-
An octave will refer to a ratio of 2:1.
-
A perfect fifth will refer to a ratio of 3:2.
-
A scale is a collection of notes, usually ordered by frequency or pitch.
Octaves
When two frequencies are an octave apart, we say that they are the same note. So, anytime we double or halve a frequency, we call it the same note. For example, the frequencies of 220Hz, 440Hz, 880Hz all correspond to the note we call $A$ (we’ll discuss modern note-naming soon).
Example
Start with a frequency of $f = 125$ Hz.
-
To go up one octave, we multiply $f$ by $2$: $2(125) = 250$ Hz.
-
To go down one octave, we multiply $f$ by $\frac12$ (or divide by $2$): $\frac12 (125) = 62.5$ Hz.
-
To go up by six octaves, we multiply by $2$ six times, or we can just multiply by $2^6$: $2^6 f = 64 (125) = 8000$ Hz.
Exercise
Start with frequency $f = 300$ Hz.
Compute the frequency one octave up from $f$ and the frequency one octave down from $f$.
Solution
One octave up: $2f = 600$ Hz.
One octave down: $\frac12 f = 15o$ Hz.
Exercise
Start with frequency $f = 50$ Hz. Compute the frequency four octaves up from $f$.
Solution
To go four octaves up, we have to double the frequency four times:
$$2\cdot2\cdot2\cdot2\cdot f = 16 f = 800 \text{ Hz}.$$
Exercise
Start with a frequency of $f = 2000$ Hz. Compute the frequency five octaves below $f$.
Solution
To go five octaves down, we have to halve the frequency five times:
$$\frac12 \cdot \frac12 \cdot \frac12 \cdot \frac12 \cdot \frac12 \cdot f = \left(\frac12\right)^5 f = 62.5 \text{ Hz.}$$
We can generalize the work we did in these exercises as follows:
To go up by $n$ octaves, we multiply a given frequency by $2^n$.
To go down by $n$ octaves, we multiply a given frequency by ${\left(\frac12\right)}^n$ or divide by $2^n$.
Perfect Fifths
The second ratio that Pythagorus identified as yielding pleasing sounds is $3:2$, which we now call a perfect fifth.
Example
Let’s start with a frequency of $f = 220$ Hz.
-
To go up a perfect fifth, we multiply $f$ by $\frac32$: $\frac32(220) = 330$ Hz.
-
To go down a perfect fifth, we divide $f$ by $\frac32$, which is the same as multiplying by $\frac23$: $\frac23(220) = 146.67$ Hz.
Exercise
Start with $f = 300$ Hz. Compute the frequency one perfect fifth above $f$.
Solution
Exercise
Start with $f = 150$ Hz. Compute the frequency one perfect fifth below $f$.
Solution
Exercise
Start with $f = 110$ Hz. Compute the frequency three perfect fifths above $f$.
Solution
We can generalize the work we did in these exercises as follows:
To go up by $n$ perfect fifths, we multiply a given frequency by $\left(\frac32\right)^n$.
To go down by $n$ octaves, we multiply a given frequency by $\left(\frac23\right)^n$..
Recreating the Pythagorean Scale
This activity is going to have two parts: First, we’ll come up with a set of fractions that we can use to create a scale using the Pythagorean approach. Then, we’ll choose a root frequency and multiply it by our fractions to get a set of frequencies.
Pythagorean Ratios
Remember that a ratio of $2:1$ is an octave and that if two frequencies are an octave apart we consider them to be the same note. So, we’ll begin by finding fractions between $1$ and $2$ that we can form using only $2, \frac12, \frac32, \text{ and } \frac23$. In other words, there are two rules:
- We multiply by $\frac32$ or $\frac23$ to get a new note.
- If we get a number less than $1$ or greater than $2$, we multiply by $2$ or $\frac12$ to get a fraction between $1$ and $2$.
- To make it easier to visualize, we’ll put everything on a number line extending from $0$ to $1$ with $\frac32$ in the middle.

-
Now, let’s multiply $3/2$ by itself:
$$\frac32\cdot\frac32 = \frac94$$
Since $9/4$ is greater than $2$, we need to bring it down by one octave - that is, we need to multiply by $1/2$:
$$\frac94\cdot\frac12 = \frac98$$

-
Let’s repeat that. Multiply by $3/2$ again: $$\frac98\cdot\frac32 = \frac{27}{16} < 2$$

-
And again: $$\frac{27}{16}\cdot\frac32 = \frac{81}{32}$$ This is greater than $2$, so we drop it by an octave: $$\frac{81}{32}\cdot\frac12 = \frac{81}{64}$$

Now that we have a set of fractions to work with, we’ll use the coding platform, Sonic Pi , to apply these fractions to audible frequencies. Sonic Pi is available for both Windows and OS X. Once you’ve downloaded it, you can go through the first few modules in the tutorial to familiarize yourself with the interface and some of the basic commands.
For this first activity, we’ll be using two simple commands: play and
sleep. The play command will play a single tone. Test it out by
entering the following in a blank code editor window and then hitting
Run: $\texttt{play hz_to_midi(200)}$
This command will generate a tone of 200 Hz.
Let’s take 200 Hz to be our starting note, or root. We can multiply each of the fractions on our number line by 200 to get a set of frequencies. For example:
-
$200\cdot\frac32 = 300$
-
$200\cdot\frac98 = 225$
Repeating this for all of the fractions we came up with above, we get the following: 200 Hz, 225 Hz, 253.125 Hz, 300 Hz, 337.5 Hz
Sonic Pi Demo Pythagorean Scale
Getting Started
Here’s our starting point for playing the notes of our Pythagorean scale.
# Pythagorean Scale
# Start by making a list of "pythagorean scale fractions"
p = [1, 9/8.0, 81/64.0, 4/3.0, 3/2.0, 27/16.0, 2.0]
# choose your starting frequency
f = 220
# We need a function that tells [Sonic Pi](https://sonic-pi.net/)
# to convert the frequencies to notes
define :N do |i|
hz_to_midi(f*p[i])
end
p.length.times do |j|
play N(j)
sleep 0.5
end
A few things to note (pun intended):
- When making our list,
p, we include the decimal points in our fractions so Sonic Pi knows not to round down. If we enter 9/8, it will round down to 1, whereas the addition of a decimal point indicates that we want a decimal calculation.- In most computer programming languages, the elements of a list are numbered starting at zero.
- To refer to a list element, we write brackets after the list name.
- So, for my list here
p[0] = 1, p[1] = 9/8.0, p[3] = 81/64.0and so on
- So, for my list here
- You can pick any starting frequency you like.
- We want to play the frequency
fmultiplied by each of the fractions in our listp. To do so, we define a function that calculates that product for us.define :N do |i|tells Sonic Pi that we’re defining a function calledNthat has an input value calledi- In more math-y notation, we would just write $N(i)$
- If we wrote
define :mynote do |x|then the function would be calledmynoteand the input would bex
- The command
hz_to_miditakes a frequency as an input and converts it to a MIDI note- MIDI stands for Musical Instrument Digital Interface.
- MIDI notes are numbered 0 - 127
- Now that we’ve written this function, we can use it to do this calculation for us.
- If I write
N(2)Sonic Pi will computehz_to_midi(220 * 81/64.0)sincef = 220andp[2] = 81/64.0
- If I write
- To play our output, we can just type
play N(2) - If we want to hear all of the notes in our scale, on after another, we could type the following:
play N[0]
sleep 0.5
play N[1]
sleep 0.5
play N[2]
sleep 0.5
play N[3]
sleep 0.5
play N[4]
sleep 0.5
play N[5]
sleep 0.5
- This is a little tedious! Instead, we can write a short iteration/loop.
p.length.times do |j|
play N(j)
sleep 0.5
end
p.lengthgets the length of the listpfor us.p.length.times do |j|tells Sonic Pi to perform a set of instructionsp.lengthtimes with an inputjthat starts at 0 and increases by one with each iteration.
Other Things to Experiment With
Use a different synth sound. In the help menu, select the synths pane to see a list of available synths.
with_synth :fm do
p.length.times do |j|
play N(j)
sleep 0.5
end
end
Play notes simultaneously outside of a loop by omitting the sleep command or putting them in a list.
play [N(0), N(2), N(3)]
Hold notes longer with the sustain parameter
play [N(0), N(2), N(3)], sustain: 3
Add audio effects. Change the value of mix to anything between 0 and 1. Look in the help for a full list of effects.
with_fx :reverb, mix: 0.8 do
with_synth :fm do
p.length.times do |j|
play N(j)
sleep 0.5
end
end
end
Loop your scale forever and add some drums!
with_fx :reverb, mix: 1 do
with_synth :fm do
live_loop :pyth do
p.length.times do |j|
play N(j)
sleep 0.5
end
end
end
end
live_loop :drums do
sample :bd_haus
sleep 1
sample :sn_dolf
sleep 1
end
live_loop :hats do
sample :drum_cymbal_closed, amp: 0.5
sleep 0.5
end
Speed things up by changing the tempo. Add use_bpm 120 to the top of your code. The default value is 60, so setting it to 120 doubles the tempo/speed. Play around with it.
Pythagorean Diatonic Scale
A scale is a collection of notes ordered by frequency (lowest to highest). The Pythagorean Diatonic Scale follows the Pythagorean construction you experimented with above to create a scale with 7 distinct notes in an octave. We consider the octave to be the same note as the root (our starting frequency).
| Root | 2 | 3 | 4 | 5 | 6 | 7 | Octave |
|---|---|---|---|---|---|---|---|
| 1 | 9/8 | 81/64 | 4/3 | 3/2 | 27/16 | 243/128 | 2 |
Notice that the fourth note has a ratio of $4:3$. Rather than using $3/2$, we flip it around to $2/3$ and then, because it’s less than 1, we multiply by 2 to get a fraction between 1 and 2.
$$\frac23\cdot\frac21 = \frac43$$
All of the other ratios follow the exact construction you experimented with above - i.e., they are all powers of $3/2$ times powers of $1/2$:
$$\left(\frac32\right)^m\left(\frac12\right)^n$$
For instance,
$$\frac98 = \left(\frac32\right)^2\left(\frac12\right)$$ $$\frac{81}{64} = \left(\frac32\right)^4\left(\frac12\right)^2$$
We could also go backwards by using negative integer exponents. E.g.,
$$\left(\frac32\right)^{-2}\left(\frac12\right)^{-2} = \frac{16}{9}$$
$$\left(\frac32\right)^{-3}\left(\frac12\right)^{-3} = \frac{32}{27}$$
This kind of construction could be carried on indefinitely. In line with modern Western musical convention, we’ll stop at twelve ratios constructed this way:
| Root | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
|---|---|---|---|---|---|---|---|---|---|---|---|
| $1$ | $\frac{256}{243}$ | $\frac{9}{8}$ | $\frac{32}{27}$ | $\frac{81}{64}$ | $\frac{4}{3}$ | $\frac{729}{512}$ | $\frac32$ | $\frac{128}{81}$ | $\frac{27}{16}$ | $\frac{16}{9}$ | $\frac{243}{128}$ |
Just intonation: revising the Pythagorean Scale
While the Pythagorean approach of using only the very pleasing ratios of $2:1$ and $3:2$ to construct a scale seems sensible, we might notice that some of the ratios we end up with in this $12$-note system have fairly large numerators and denominators: look at the second, fifth, seventh, and twelfth notes, for example.
Pythagorus was right that small ratios produce pleasing sounds. The reason has to do with the overtone series we discussed in the previous chapter.
Overtones and Intervals
Consider a violin string vibrating at $f = 220$ Hz. The pitch we hear corresponds to $220$ Hz, but this is only one of many vibrations coming from the violin. Recall that the violin’s timbre corresponds to the many overtones it generates. These overtones, as we saw, are all whole-number multiples of $220$ Hz. Let’s list the first several overtones:
| $f$ | $2f$ | $3f$ | $4f$ | $5f$ | $6f$ |
|---|---|---|---|---|---|
| $220$ | $440$ | $660$ | $880$ | $1100$ | $1320$ |
Let’s look at the ratios between these overtones:
-
Notice that the first overtone is one octave higher than $f$.
-
The second overtone, $3f$, is a perfect fifth above the octave, $2f$.
Exercise
There are many more octaves and perfect fifths embedded in the overtone series. List two more octave pairs and two more perfect fifth pairs. You may have to write out more of the overtone series to do so.
You should state which overtones make a pair, and what the frequencies are.
E.g.,
-
$f$ and $2f$ are an octave apart because $2f$ is $2 \cdot f$ (of course). The frequencies are $220$ Hz and $440$ Hz.
-
$2f$ and $3f$ are a perfect fifth apart because $3f = \frac32 \cdot 2f$. The frequencies are $440$ Hz and $660$ Hz.
Solution
Octave pairs:
-
$2f$ Hz and $4f$ are an octave pair.
-
$3f$ and $6f$ are an octave pair.
-
$4f$ and $8f$ are an octave pair.
Perfect fifth pairs:
-
$4f$ and $6f$
-
$6f$ and $9f$
Isn’t this incredible? Within a single note played by a violin or sung by a human, there are octaves and perfect fifths. So, is this why these intervals sound pleasing to us? Because they are inherent in all naturally occurring pitched sounds? Think on it.
Just Intonation
What about the large-number ratios in the Pythagorean scale? To find a ratio of $81 : 64$, we would have to go out $80$ overtones! For a frequency of $220$ Hz, which isn’t all that high, the $80^{\text{th}}$ overtone would have a frequency of $17,820$ Hz. This is on the very edge of the range of human hearing and is unbelievably high-pitched.
So, this suggests that, even though the Pythagorean method uses small-number ratios as building blocks, some of the resulting ratios are really “out of tune” with respect to naturally occurring overtones. Another mathematician and music theorist from the ancient world, proposed an alternative to the Pythagorean scale. Ptolemy, who was born around 100 AD, came up with a scale we now refer to as the justly tuned major scale - also called the just major scale.
Rather than use the perfect fifth to construct all of the notes within the octave, the justly tuned major scale prioritizes small number ratios. These ratios aren’t too far off from the one’s in the Pythagorean major scale, but, by using much small numbers, we get a scale that is more in tune with the overtone series. For example, rather than multiplying or root note by $\frac{81}{64}$ to get our fifth note, we use $\frac{5}{4}$ instead. In comparing these, we find that $\frac{81}{64} = 1.265625$, whereas $\frac54 = 1.25$. These are quite close, but the ratio of $5:4$ can be found within the first four overtones.
Here’s the full justly tuned major scale:
| Root | 2 | 3 | 4 | 5 | 6 | 7 | Octave |
|---|---|---|---|---|---|---|---|
| 1 | 9/8 | 5/4 | 4/3 | 3/2 | 5/3 | 15/8 | 2 |
Exercise
Start with a root frequency of $f = 220$ Hz.
Write out the frequencies for each note in the Pythagorean scale and the just major scale. Put these in a table.
Exercise
The root, third note, and fifth note, form what we call a major triad - we’ll learn more about this in the next chapter.
Try the following code to listen to the major triad in three different tuning systems. Just replace $\texttt{pyth}$ with $\texttt{just}$ or $\texttt{equal}$ to hear the different.
root = 220
pyth = [ hz_to_midi(root),
hz_to_midi(root*81.0/64),
hz_to_midi(root*3.0/2) ]
just = [ hz_to_midi(root),
hz_to_midi(root*5.0/4),
hz_to_midi(root*3.0/2) ]
equal = [ hz_to_midi(root), hz_to_midi(root) + 4, hz_to_midi(root) + 7]
play pyth, sustain: 2