I love music. I love singing. I love playing the piano. I love listening to music. Certainly not most important, but also among my loves, is understanding the science behind music.
Among the most basic understandings for western music is how harmony works. Harmonics is the physics (and, by necessity, the maths) behind the sounds. If you pick a note, say C, and designate its frequency (the 'speed' with which its sound wave oscillates) as 1, then the C exactly one octave above that will have a frequency of 2. Moving up an octave is defined as doubling the frequency. This higher C is called the second harmonic of the lower C, which itself is called the fundamental.
(By the way, the norm is to define the A above middle C on a piano as 440 Hz and to build all of the other notes off of that, but we'll stick to a C-to-C scale, which more people are used to dealing with).
The third harmonic is the note whose frequency is three times that of the fundamental. That note is one octave plus a fifth above the original C. In this case, it is the G above the upper of the two Cs we've defined so far. To get the G that resides in the octave between our two Cs, we have to divide the frequency of the third harmonic by two to bring it down an octave.
Having built the two Cs and the G, we can move in both forward and backward directions in the 'circle of fifths' to build the rest of the scale. For instance, D is a fifth up from G. A is a fifth up from D, etc. Similarly, F is a fifth down from C. B♭ is a fifth down from F, etc.
The entire sequence of fifths (with C in the middle) is:
Since G♭ is the same as F#, the sequence becomes a circle. But wait, although we're used to G♭ and F# being the same note, that is only because most of us learn music with a piano or guitar - fixed pitch instruments that use the modern even-tempered scale, which we'll come to in a bit.
Actually, building the scale based on pure harmonics does NOT give us a G♭ equal to F#. Without boring you (perhaps I'm too late) with the steps that get us there, the notes and their relative frequencies end up working like this:
C - 1; D♭ - 256/243; D - 9/8; E♭ - 32/27; E - 81/64; F - 4/3
F# - 729/512; G♭ - 1024/729
G - 3/2; A♭ - 128/81; A - 27/16; B♭ - 16/9; B - 243/128; C - 2
You can use your calculator (!) to confirm that those F# and G♭ fractions are not equal.
Despite the dizzying array of fractions, the progression from the lower C to the higher one is relatively, if not perfectly, smooth. The percentage increase in frequency for any semi-tone move up the scale is either 5.35% (for C-D♭, D-E♭, E-F, F-G♭, F#-G, G-A♭, A-B♭ and B-C) or 6.79% (for D♭-D, E♭-E, F-F#, G♭-G, A♭-A and B♭-B).
Because the steps are not of uniform size, a song can sound quite different in different keys (i.e. depending on what note the song starts on). Different musical eras have used different approaches to get round this 'imperfection'. Bach would have written his pieces for a specific key because of the 'feel' that key had.
Now, back to the piano and guitar (and all other fixed pitch instruments) of today. For some time now, the music world has been using what is called an even-tempered scale. One in which the sizes of the steps from the lower C to the higher one are all the same. As it turns out, to double the frequency over the course of twelve uniform steps, each note needs to have a frequency 5.95% greater than the note below it. Unsurprisingly, this interval lies between the sizes of the two intervals (5.35% and 6.79%) in the 'pure' or 'perfect' harmonic scale.
There is a cost to this simplicity, but one only borne by the most sensitive of ears. None of the intervals / harmonies produced by the even-tempered scale is perfect. Each is slightly off what physics calls for. These days, nearly all of us are attuned to this minor blemish, but we should all recognise that the harmonies we hear, while undeniably beautiful, are sadly not perfect.