Why did we settle on 12 notes?

Rule 1 (also stated in the article): Doubling frequency gives us practically the same note. It is so pleasant together with the original note, that it is boring.

Lets make a set of notes that sound nice together, and are more or less equally distributed between a note and its frequency double (octave).

The next most pleasant note, is a note with 3 times the frequency, then 4, etc...

(Why is this pleasant? Because its a close natural harmonic. When you vibrate a string with frequency 1, it will start vibrating with a frequency of 2 as well, but softer. This doubling in frequency is because the string will behave both as a string with length L, and as two separate strings with length L/2. Because the length is halve, the frequency is doubled.)

Now, 3 times the frequency, is the same as 1.5 times the frequency. If we do the same from that base note, we get 1.5 * 1.5 = 2.25 times the frequency. You could decide that that 2.25 is close to 2, call it a day, and settle on a two note scale.

Or, you go further. 2.25/2 = 1.125, so now we have the notes 1, 1.125, 1.5 and 2. Not really evenly spaced yet. 1.125*1.5=1.6875...: [1, 1.125, 1.265, 1.5, 1.687, 1.89]. Oh, 1.89 is almost 2. Let's call it a day and settle on a five note scale. (there are plenty of cultures with a five not scale folk music tradition).

Note that the error gets smaller, it was 2.25/2 for our 2 note scale, it's 1.89/2 for the 5 note scale. Now it happens that the next smallest error is with a 12 note scale. But there's still an error, you don't arrive at exactly 2. The intervals between your notes are not even, and your last interval is all retarded.

That's why people settled on "equal temperament", where all the intervals between the notes are made equal, and the number 12 looks seemingly arbitrary.

I did the math, see table below. The first column are the frequency of the notes, with base frequency 1, where I multiplied by 1.5, and divided by 2 to keep the notes between frequency 1 and 2. The 4th column gives you the "error", how close is the last note of the scale, to the octave of the base note. The closer it is, the better, it means we have an equally divisible range of notes that all have nice (with ratio 1.5) intervals with each other.

The arrows indicate where we could stop adding notes to our scale, because we arrived at a local optimum: a five not scale is small but has quite an error. The 12 note scale is quite elaborate, but reduces the error a lot. The next best scale would be a 41 note scale, with only a slightly diminished error compared to the 12 note scale.

Freq. n/1 2/n min(n/1;2/n)
1.500 1.50 1.33 1.333
1.125 1.13 1.78 1.125
1.688 1.69 1.19 1.185
1.266 1.27 1.58 1.266
1.898 1.90 1.05 1.053 <-- (5 notes)
1.424 1.42 1.40 1.405
1.068 1.07 1.87 1.068
1.602 1.60 1.25 1.249
1.201 1.20 1.66 1.201
1.802 1.80 1.11 1.110
1.352 1.35 1.48 1.352
1.014 1.01 1.97 1.014 <-- (12 notes)
1.520 1.52 1.32 1.315
1.140 1.14 1.75 1.140
1.711 1.71 1.17 1.169
1.283 1.28 1.56 1.283
1.924 1.92 1.04 1.039
1.443 1.44 1.39 1.386
1.082 1.08 1.85 1.082
1.624 1.62 1.23 1.232
1.218 1.22 1.64 1.218
1.827 1.83 1.09 1.095
1.370 1.37 1.46 1.370
1.027 1.03 1.95 1.027
1.541 1.54 1.30 1.298
1.156 1.16 1.73 1.156
1.734 1.73 1.15 1.153
1.300 1.30 1.54 1.300
1.951 1.95 1.03 1.025
1.463 1.46 1.37 1.367
1.097 1.10 1.82 1.097
1.646 1.65 1.22 1.215
1.234 1.23 1.62 1.234
1.852 1.85 1.08 1.080
1.389 1.39 1.44 1.389
1.041 1.04 1.92 1.041
1.562 1.56 1.28 1.280
1.172 1.17 1.71 1.172
1.758 1.76 1.14 1.138
1.318 1.32 1.52 1.318
1.977 1.98 1.01 1.012 <-- (41 notes)