I just set off a new trip to the wonderful world of fretted instruments. I bought myself an electric bass guitar (cort c4h). My question to you is what is the formula of the fret distances along the fretboard. How interfret distance diminishes as you play higher notes. As a professional researcher (HEP physics) I would like to know exactly the theoretical background. I did an online search but still I am not persuaded.
In a 12-tone, equal tempered scale, we want our frequency to double (become an octave higher) every 12 semitones, and we want our semitones to be evenly-spaced.
As each fret represents a semitone, and the fundamental frequency of oscillation of an ideal string is proportionate to the reciprocal of its length, this means that every fret should be a factor of the 12th root of 2 ≈ 1.06(ish) times further from the bridge than the previous one.
So, for example, when you move from the 12th fret right to the nut, you've multiplied that spacing by 1.06ish 12 times - so the fret spacing between the nut and first fret half of what it is at the 12th fret. Wikipedia even has an amusingly specifically-titled article, Twelfth root of two, that shows how repeatedly multiplying by the number produces the equal-tempered chromatic scale.
The way the '17.817' mentioned in Laurence's answer is calculated is this:
The reason for the more complex sums here is that this number is used when talking about working out the ratios from the nut. If we imagine that the whole string length is 1, then 1/17.817 is 0.05612ish, so the length of the string when fretted at the first fret is (1-0.05612) = 0.94388. And when we work out 1/0.94388 (i.e. the ratio of the whole length of the string compared to its length when fretted at the first fret), it gets us back to that 1.06ish ratio (12th root of 2). Phew!
Sometimes slightly different fret spacing may be used to compensate for non-ideal characteristics of strings (and, as Laurence says, the slight tension increase that results in displacing the string when fretting it).
As a mathematician, I'm sure you already know the basic theoretical answer. Quoting from the first link given below:
"If you divide the scale length (the distance from the nut to the bridge) by 17.817, you end up with the first fret position starting from the nut end of the fingerboard. If you then take the scale length minus the first fret distance and divide the remainder by 17.817, you end up with the second fret position located from the first fret. Next if you take the scale length minus the first and second fret distances and divide the remainder by 17.817, you end up with the third fret position located from the second fret. This process is repeated until all frets required are located."
But the string has to be pushed down to the fret, and this increases tension. Read the whole paper:
And here's a less mathematical discussion of the subject: