If a note has a fundamental frequency of 100Hz, then its second harmonic is located at 200Hz and its tenth harmonic is located at 1000Hz. But for acoustic instruments, the harmonics will not occur at exact multiples of the fundamental. My question is, how much error is typical and what is the relationship between the degree of error and the harmonic number. So for example, is it common for the error in the tenth harmonic to be as much as, say, 50Hz. 1050Hz in other words. That's a 5% error. But would a 5% error be just as likely for the second harmonic?
how much error is typical and what is the relationship between the degree of error and the harmonic number
I think that's hard to answer. Do you want to include contrived weird instruments with terrible inharmonicity? Inherently inharmonic instruments that are manipulated to sound roughly harmonic, like bells and tympani?
I started writing a program to analyze all of the Musical Instrument Samples Database and measure the inharmonicity of each harmonic, which would answer your question exactly for all those instruments, but I didn't finish it yet. :) Here's a preliminary test graph, to give you a rough idea:
X axis is harmonic number, Y axis is frequency relative to a perfect multiple. If the fundamental is 100 Hz, for instance, and the 2nd harmonic is 210 Hz, it will be mapped to 210/200 = 1.05. The blue and green are piano tones (I didn't write down the fundamental frequency I used for this graph). Purple and yellow are guitar. Struck or plucked strings are inharmonic, with higher partials sharper than true harmonics. The red and teal are double bass. Bowed strings are perfectly harmonic because of the slip-stick motion of the bow. (Though there are weird jumps at the 2nd or 3rd harmonic. Not sure what those are from.)
The flattening out at the top right is definitely wrong, due to the algorithm "locking onto" things that are not actually harmonics.
So for piano, you have to go up to the 25th partial to get 5% out of tune. The 2nd partial is less than 1% off. At the extremes, the 50th partial is maybe 13% sharp from the pure 50th harmonic.
A few things:
- Not all instruments have partials neatly defined by the $h_n = nf$. Kettle drums would be an obvious example, but bells are another. In this case, you will be way off looking in the "usual places" +/- 5%.
- Many instruments have only even or odd harmonics. Others are designed to omit some harmonics. The piano, for example, is designed to have almost no 7th harmonic. This may not matter to you, but it's worth pointing out in case it does.
- It is common for higher harmonics to be "out of tune", that is, not in the "usual places". An engineer who once worked as a piano tuner once admonished me for using harmonics to tune my upright bass (a technique that works well for lighter-stringed instruments), because, he said, the partials are more out of tune with heavier stringed instruments. He said it's especially true told of higher harmonics, explaining that the math that gives you the simple formula for partials assumes that strings have no mass. 5% strikes me as a little much (almost a semi-tone!), but I don't think it's out of the question.
- Many instruments have vibrato. This throws all your harmonics out of wack:
The idea that the higher harmonics are exact multiple of the fundamental is only true for a model that is a) pure linear, b) continuous , and c) only one-dimensional. Nothing of that is true in reality. The exact reason why it is for the piano exactly the way it is I cannot answer. But the main reason is nonlinearity in combination with the fact that even a string must be treated three-dimensional if one is interested in the details.