Any moderately curious person will ask themselves at some point why, in western music, is the octave divided into 12 'semitones'. From a mathematical point of view, we can easily explain why 12 works nicely.
The Greeks realized that sounds which have frequencies in rational proportion are perceived as harmonius. For example, a doubling of frequency gives an octave. A tripling of frequency gives a perfect fifth one octave higher. They didn't know this in terms of frequencies, but in terms of lengths of vibrating strings. Pythagoras, who experimented with a monochord, noticed that subdividing a vibrating string into rational proportions produces consonant sounds. This translates into frequencies when you know that the fundamental frequency of the string is inversely proportional to its length, and that its other frequencies are just whole number multiples of the fundamental. (actually, the notion of consonance is more complicated than rationality see, for example, this fascinating article ).
First, we should examine what ratios are "meant" to exist in the western scale. The prominence of the major triad in western music reflects the Greek discoveries mentioned above. Starting with the note C as a fundamental, we get the major triad from the 3rd and 5th overtones, dropping down one and two octaves respectively, obtaining ratios of 3/2 (G:C) and 5/4 (E:C) respectively. Two other prominent features in western music include the V I cadence, and the I,IV,V triads. Both reflect the importance of the 3/2 ratio, with the IV further taking into account the reciprocal of 3/2, namely 2/3 aka 4/3. Musically, the reciprocal ratio corresponds to going down rather than up. While 3/2 corresponds to going up a fifth, 2/3 corresponds to going down a fifth, and 4/3 corresponds to going down a fifth and up an octave. Together, 3/2 and 4/3 divide the octave, so that going up by 3/2 followed by 4/3 gives an octave.
The IV and V triads give us the four new notes, B and D of
G,B,D, and F and A of F,A,C. Their ratios, relative to C are
15/8 for B, 9/8 for D, 4/3 for F, and 5/3 for A. The
notes formed from the I,IV, and V major triads produce the C major
scale: C D E F G A B C. Throwing in reciprocals for
each of these intervals yields all the intervals that
made up western music until the rise
of chromaticism.
1/1 unison C 2/1 octave C 3/2 perfect fifth G 4/3 fourth F 5/4 major third E 8/5 minor 6th Ab 6/5 minor 3rd Eb 5/3 major 6th A 9/8 major 2nd D 16/9 minor 7th Bb 15/8 major 7th B 16/15 minor 2nd C#
While this list of intervals does include a few of the most basic intervals and their reciprocals: unison, perfect 5th, major 3rd, major 6th = 3rd above a 4th (or also a 4th above a 3rd), major 2nd = a 5th above a 5th, and major 7th = a 3rd above a 5th (or also a 5th above a 3rd), some obvious ones are missing (such as 7/4, 25/16 = a 3rd above a 3rd, or 9/5 = a fifth above a minor 3rd).
The tritone (such as C to F#) is also omitted from this list, an interval that did not affect the evolution of the western scale as it was not used in western music until twelve note chromaticism had become firmly established. Actually, a tritone refers to two different possible intervals:
7/5 tritone 10/7 also called a tritone.
The idea behind twelve is to build up a collection of notes using just one ratio. The advantage to doing so is that it allows a uniformity that makes modulating between keys possible. Without a compromise most keys would be unusable as most of the basic intervals would not be captured in the different keys (see the table at the end of this essay).
Unfortunately, no one ratio will do the trick exactly. However, the ratio of 3/2 happens to work reasonably well using 12 steps. With 3/2 as the basis for the scale, none of the above ratios besides a unison, fifth, and major 2nd are captured exactly.
However the most important constraint namely that we get a repeating pattern going up in octaves, is almost satisfied by this scheme. Namely, after 12 applications of the ratios 3/2, we come back very close to where we started from (always dropping down by an octave, i.e. dividing by 2, each time the ratio exceeds 2):
(3/2)^0 = 1 (3/2)^1 = 1.5 (3/2)^2 = 1.125 (after dividing by 2) (3/2)^3 = 1.6875 (after dividing by 2) (3/2)^4 = 1.2656 (after dividing by 4) (3/2)^5 = 1.8984 (after dividing by 4) (3/2)^6 = 1.4238 (after dividing by 8) (3/2)^7 = 1.0678 (after dividing by 16) (3/2)^8 = 1.6018 (after dividing by 16) (3/2)^9 = 1.2013 (after dividing by 32) (3/2)^10 = 1.8020 (after dividing by 32) (3/2)^11 = 1.3515 (after dividing by 64) (3/2)^12 = 1.0136 (after dividing by 128)we have returned close to where we started from. (these 12 frequencies correspond to the circle of 5ths. Starting from C, we then get G D A E B F# C# Ab Eb Bb F and back to C).
The chromatic scale reflects this fact. In the 18th and 19th centuries, the chromatic scale was tuned using the idea of 3/2. In the most elegant of these, Thomas Young's tuning, several of the fifths were set exactly to 3/2, and the others were tempered slightly (to make octaves exact).
In the modern equal temperament (which came into practical use during the early part of the 20th century), all fifths are tuned to 2^(7/12)=1.49651..., slightly less than 3/2, and 12 repetitions of this ratio gets us back to where we started (after dropping down 7 octaves).
Between the two methods of incorporating 3/2, the former gives the various keys character, and I prefer it highly. See the essay I wrote on this.
Of the various intervals, the only ones that are really well captured by tempered versions of the 3/2 scheme are: unison, 5th, major 2nd, and their reciprocals (octave, 4th, minor 7th).
Two questions: why 3/2? The choice of 3/2 says that, next to the octave, it should be regarded as the most important interval. One can also use a major 3rd (i.e. ratio of 5/4) to build up a scale. This is discussed towards the end of this essay.
Why do 12 steps work nicely? Interestingly, this can be explained in terms of simple number theory, namely continued fractions.
We want to understand when a power of 3/2 will be close to a power of 2:
a b (3/2) = 2 where a and b are natural numbersOf course, this equation can't be solved exactly using natural numbers a and b, since this would imply, once we clear denominators, that a power of 3 was a power of 2 (an impossibility since powers of three are odd, whereas powers of 2 are even. Such an expression would also contradict the fact that each integer is *uniquely* expressible, up to order, as a product of primes). But, taking the ath root of both sides:
b/a (3/2) = 2we are led to look at the equation
x (3/2) = 2 where x is a real numberand ask for rational numbers b/a that are close to x. Taking the log of both sides, and solving for x we find that x = log(3/2)/log(2) = .584962500721... To find good rational approximations to this number we should turn to the socalled continued fraction of x. Any real number can be written as a continued fraction, which is a crazy looking fraction that, unless the original number happens to be rational, goes on forever. In our case, the first few terms of the continued fraction looks like this
log(3/2)/log(2) = 1  1 1 +  1 1 +  1 2 +  1 2 +  1 3 +  1 1 +  1 5 +  1 2 +  1 23 +  2 + ...(the expansion has 1's in the numerators and continues forever).
Taking the first few terms leads to the following sequence of rational approximations to log(3/2)/log(2) = .584962500721...:
1  = 1/2 1 1 +  1 1  = 3/5 1 1 +  1 1 +  2 1  = 7/12 1 1 +  1 1 +  1 2 +  2 1 24  =  1 41 1 +  1 1 +  1 2 +  1 2 +  3 etcIt is the approximation 7/12 = .5833333333... which suggests an octave of 12 steps, with a fifth equal to 7 semitones.
Why have we looked at continued fractions: it turns out that they give the best rational approximations to numbers, i.e. any closer approximation must have a larger denominator.
If one, similarly, forms the continued fraction for log(5/4)/log(2)=.32192809..., one finds the following list of approximating fractions: 1/3, 9/28, 19/59, 47/146, etc. This suggests, for example, that a 28 note scale would work nicely using the major 3rd as the basis for its construction.
On the other hand, we need not always work with the best. For example, 11/19 = .5789... is reasonably close to log(3/2)/log(2) = .5849..., and 6/19 = .3157... is reasonably close to log(5/4)/log(2)=.3219.... This suggests that a 19 note scale with a major 3rd being 6 'semitones' and a perfect 5th being 11 'semitones' might work nicely. In fact, 19 appears in the denominators of rational approximations of the continued fractions for log(5/3)/log(2), and log(6/5)/log(2). This says that 19 would also work well for capturing the reciprocal pair of ratios 5/3 and 6/5.
If we use an equal tempered 19 note scale, we get the following list of ratios
k/19 k 2 nearby ratio    0 1 unison * 1 1.0371550444461919861 28/27 2 1.0756905862201824742 14/13 close to 16/15 minor 2nd * 3 1.1156579177615436668 10/9 close to major 2nd (9/8) * 4 1.1571102372827198253 7/6 also close to 8/7 5 1.2001027195781030358 minor 3rd (6/5) (see how well this one fits) * 6 1.2446925894640233315 major 3rd (5/4) * 7 1.2909391979474049134 9/7 8 1.3389041012244721773 major 3rd (4/3) * 9 1.3886511426146561750 tritone (7/5) * 10 1.4402465375387590116 tritone (10/7) * 11 1.4937589616544857174 5th (3/2) * 12 1.5492596422666557249 14/9 13 1.6068224531337648149 minor 6th (8/5) * 14 1.6665240127970890861 major 6th (5/3) (see how well this one fits) * 15 1.7284437865632111533 12/7 also close to 7/4 16 1.7926641922757116385 9/5 close to minor 7th (16/9) * 17 1.8592707100168125609 13/7 close to major 7th (15/8) * 18 1.9283519958849901632 27/14 19 2 octave * *'s indicate notes that have a corresponding spot (more or less) in the 12 note octave.I'm not sure if this scale has been used extensively by anyone, though it seems to be an interesting alternative to the 12 step chromatic scale. Conceivably, a nice welltempered version could be devised. There are some 19 tone pieces at a certain web site Look at Joseph Pehrson, and Neil Haverstick who use various 19 tone tunings.
I found a link that talks about the history of 19 tone tunings.
The following table depicts in cents (percentage of a semitone), how poorly a justly intoned piano tuned in the key of C would do in capturing the various intervals in the various keys. This is compared, in the last column, against equal temperament. For example, the table says, that in the key of A, a major third would be off by 41% of a semitone. Notice in the last column, that, while equal temperament captures the intervals 3/2, 9/8, 4/3, and 16/9 quite well, the other intervals are all off by more than 11% of a semitone.
C 
G 
D 
A 
E 
B 
F# 
C# 
Ab 
Eb 
Bb 
F 
E.T. 

1 
0.00 
0.00 
0.00 
0.00 
0.00 
0.00 
0.00 
0.00 
0.00 
0.00 
0.00 
0.00 
0.00 
16/15 
0.00 
0.00 
0.00 
0.00 
0.00 
0.00 
7.71 
19.55 
41.06 
41.06 
19.55 
27.26 
11.73 
9/8 
0.00 
21.51 
21.51 
0.00 
7.71 
19.55 
27.26 
0.00 
21.51 
21.51 
0.00 
0.00 
3.91 
6/5 
0.00 
21.51 
21.51 
0.00 
0.00 
0.00 
13.79 
41.06 
41.06 
48.77 
0.00 
0.00 
15.64 
5/4 
0.00 
0.00 
7.71 
41.06 
41.06 
41.06 
27.26 
0.00 
0.00 
0.00 
21.51 
0.00 
13.69 
4/3 
0.00 
0.00 
0.00 
21.51 
0.00 
0.00 
7.71 
27.26 
0.00 
0.00 
21.51 
0.00 
1.96 
7/5 
0.00 
27.26 
27.26 
48.77 
27.26 
27.26 
34.98 
7.71 
7.71 
13.79 
7.71 
7.71 
17.49 
3/2 
0.00 
0.00 
21.51 
0.00 
0.00 
7.71 
27.26 
0.00 
0.00 
21.51 
0.00 
0.00 
1.95 
8/5 
0.00 
0.00 
21.51 
0.00 
0.00 
0.00 
7.71 
41.06 
41.06 
41.06 
27.26 
0.00 
13.69 
5/3 
0.00 
0.00 
0.00 
13.79 
41.06 
41.06 
48.77 
0.00 
0.00 
0.00 
21.51 
21.51 
15.64 
16/9 
0.00 
0.00 
0.00 
21.51 
21.51 
0.00 
7.71 
19.55 
27.26 
0.00 
21.51 
21.51 
3.91 
15/8 
0.00 
7.71 
19.55 
41.06 
41.06 
19.55 
27.26 
0.00 
0.00 
0.00 
0.00 
0.00 
11.73 