We saw from one of my previous posts that we can’t choose the notes of the musical scale such that, from every note, an interval of a perfect octave (ratio of 2:1) and a fifth (ratio of 3:2) is available. In this post, I will explain how this problem is fixed in the modern musical scale.

If we’re going to have both the octave and the fifth, then one of them will have to be an approximation. We’ll cheat and alter the fifth – there have been some proposed scales that alter the octave, but these are non-standard. We want a ratio (call it r) that is nearly a fifth, so that, for some whole numbers and :

m (approximate) fifths = n octaves

where r is close to 3/2. Then, since each power of r produces a new note in the scale, we generate a scale with m notes. (For those who know about these things, this means that the set of ratios of the notes in a scale, and the operation of multiplying by r (and dividing by 2 if necessary), form a **group** with m elements.)

Is there an optimal way of choosing r? Let’s return to the equation that caused all the problems in my last post:

We can rewrite this as:

We have seen that this equation has no solution, but if we could find whole numbers m and n, so that:

then we can write r as:

and we have found r. (Do it for yourself!)

How do we find a rational approximation to an irrational number ? Here we turn to the mathematical tool of continued fractions. A continued fraction is an expression such as:

where are all positive whole numbers (for positive ). We can write this in the form:

Every real number has a unique expression as a continued fraction (unlike decimals, where, for example, 1 = 0.999 …). If is rational, then the set of is finite; if is irrational then the set of is infinite. Given , there is an algorithm for generating the : you can find it here or work it out for yourself.

We can also define the nth convergent of the continued fraction, which is a rational number:

Now the most important fact about continued fractions can be found here (theorem 5, corollary 1):

*“Any convergent is nearer to the continued fraction than any other fraction whose denominator is less than that of the convergent”.*

In other words, continued fractions provide the best way to approximate an irrational number by a rational one. Further, if is large, then is a particularly good approximation to . So let’s look at the continued fraction for

The convergents of are:

Now, remember that the denominator is m, the number of notes in the scale. Five is too few, and forty-one is too many – an 88 key piano would only cover about 2 octaves, and with frequencies separated by about 1%, it would be difficult for the ear to distinguish adjacent notes, especially if played rapidly. It would be even more difficult for a human to sing these closely spaced notes accurately.

But twelve is just about right, and approximates 3/2 to within 0.1% – better than the frequency resolution of the human ear. Now that we have r, we can generate the ratios of the notes of the musical scale. We find that, because 7 and 12 have no common factors, the notes of the musical scale can be generated by continual multiplication (or division) by the ratio – the ratio of a semitone, the smallest interval. The scale, generated in this way, is said to be equally tempered. This is the modern musical scale.

As this point I will refer you to this table of intervals in Wikipedia, which lists the ratios along with the nearest whole number ratio (known as a just intonation). The far right column lists the difference between an equally tempered interval and a “just” interval in cents – all that is relevant here is that humans can discern a difference of 5 cents or more. You can see from the table that, apart from the fifth (which we chose ourselves), the perfect fourth (which is the inverse of the fifth – i.e. going up a fourth is the same as going down a fifth) and major second, all of the intervals are noticeably different from their ideal, whole-number-ratio values. Thus, the imperfection of the musical scale is always present in music. Whether the brain hears it, and how the brain perceives sound in general, is a field known as psychoacoustics , but that’s a topic for another day.

on June 9, 2008 at 1:17 am |Owen“Every real number x has a unique expression as a continued fraction”

Not so. Consider the continued fraction [0;2] – This equates to decimal 0.5. Now consider the cf [0;1,1]. This also equates to 0.5. In general, the cf [a_0;a_1,a_2,…,a_n] can be written [a_0;a_1,a_2,…,-1+a_n,1] (written that way so as to avoid confusion with a_(n-1)!

on June 9, 2008 at 1:18 am |OwenPlease feel free to mentally add a closing parenthesis to my previous comment!

on June 9, 2008 at 1:43 am |Tim McKenzieInteresting post. I have a question, and a few minor quibbles. My question is related to one of my minor quibbles, so I’ll start with that.

You say that the Wikipedia table “lists the ratios along with the nearest whole number ratio (known as a just intonation)”. It doesn’t do that, since there’s no such thing as “the nearest whole number ratio” to an irrational number. Instead, it appears to be listing the ratios that the equal-temperament notes are purporting to approximate. How do we decide which notes they’re purporting to approximate? Counting seven notes at a time (and looping around when necessary), we see that the perfect fifth corresponds to 3/2 and the major second to 9/8, as we expect from your explanation involving powers of 3/2. But then the major sixth corresponds to 5/3, instead of 27/16, as we would expect if we were just looking at powers of 3/2. Why do we say that we’re approximating 5/3 there?

The next quibble is very minor. In your explanation of continued fractions, you say that the “a_n are all positive whole numbers (for positive x)”. But a_0 can be 0 if x < 1 (e.g. when x = log_2 (3/2)).

My other quibble is that rational numbers don’t have unique continued fraction expansions. For example: 3/2 = [1;2] = [1;1,1].

Also related is http://www.math.uwaterloo.ca/~mrubinst/tuning/12.html from Michael Rubinstein’s website. (He taught me half a course in analytic number theory before my health forced me to drop it.)

(By the way, is it possible to enter LaTeX in comments? If so, can we have an option to preview comments before we post them, please?)

on June 9, 2008 at 7:51 am |lukebarnesWell spotted, lads!!!

I should have read the Wikipedia page more carefully. The correct statement is:

“The continued fraction representation of any rational number is unique if it has no trailing 1.”

Irrational numbers have no trailing so it’s not a problem. Also, we need to add that need not be positive.

Regarding the nearest whole number ratio, again you’ve caught out some sloppiness on my part. There is no unique way of associating each equal-tempered note with a whole number ratio. However, just intonation is an alternative to equal-tempering to overcome the problem of Part 1. It uses whole number ratio, and simply tolerates the fact that they don’t match up. In Pythagorean tuning (an example of just intonation), we start at C (ratio of 1:1) and move out in ratios of 3:2 in both directions. The result is that Gb does not equal F# – the difference is 24 cents (known as the Pythagorean comma).

As just intonation is in the business of using whole number ratios for musical intervals, it seems to be the best candidate for comparison with the equal-tempered scale, even if the comparison is not unique.

on June 9, 2008 at 7:59 am |lukebarnesAlso, here’s how to put latex math into your comments:

http://faq.wordpress.com/2007/02/18/can-i-put-math-or-equations-in-my-posts/

It worked in my comment. I don’t know how to preview your comments. I’ll see what I can find out.

on June 11, 2008 at 5:13 am |Tim McKenzieThanks! I might be brave enough to use simple in comments in the future, but I probably won’t try complicated stuff without a preview.

on June 11, 2008 at 5:14 am |Tim McKenzie“Formula does not parse”? That’s why I’m reluctant to use it without a preview.