# Why do the Fourier components of a piano note shift away from the harmonic series?

This comes from me answering a question about functionally modeling a piano playing a middle C note in Mathematica.

I figured the note would consist of the fundamental frequency f0 ~ 440 × 2−9/12 Hz and a bunch of harmonic over/undertones that are integer (or 1 over an integer) multiples of the fundamental frequency.

Indeed, if we plot the absolute values of the discrete Fourier transform (this is for a short time interval near the attack of the note), we see the dominant frequencies lie on integer multiples of the fundamental frequency:

However, as we move to higher overtones, the peaks start to deviate away from integer multiples of f0. My question is what is causing this deviation? Shouldn't it just be integer multiples of the fundamental frequency vibrating on the piano string? Is this expected behavior for a piano?

This is a phenomenon called inharmonicity, in which harmonics deviate from the expected integer multiples. This is an example of the difference between ideal mathematics and the real world. Wikipedia has a good description that relates directly to piano inharmonicity:

Music harmony and intonation depends strongly on the harmonicity of tones. An ideal, homogeneous, infinitesimally thin or infinitely flexible string or column of air has exact harmonic modes of vibration.1 In any real musical instrument, the resonant body that produces the music tone—typically a string, wire, or column of air—deviates from this ideal and has some small or large amount of inharmonicity. For instance, a very thick string behaves less as an ideal string and more like a cylinder (a tube of mass), which has natural resonances that are not whole number multiples of the fundamental frequency. (https://en.wikipedia.org/wiki/Inharmonicity)

Wikipedia also includes a section specifically devoted to piano inharmonicity, which discusses string thickness as the primary influence on the instrument's inharmonicity.

The Railsback curve "expresses the difference between inharmonicity-aware stretched piano tuning and theoretically correct equal-tempered tuning in which the frequencies of successive notes are related by a constant ratio, equal to the twelfth root of two." Stretched tuning is the technique of adjusting the high and low strings on a piano slightly sharp and flat, respectively, to account for their inharmonicity.

• I believe (by memory) that imprecision in harmonics contributes significantly to the timbre of a particular instrument, on top of the relative amplitudes of the harmonics themselves.
– Slate
Commented Jul 12 at 14:39
• @Slate I decided to look into this. Here I compare 2 reconstructions I made to the original sound (make sure to unmute the audio). The first note is the original sound, the 2nd was made by finding the true peak frequencies of the DFT near the attack of the note and fitting each peak's intensity by least squares, and the last was made by shifting the peaks to the nearest harmonic. The first reconstruction with true peak location is a little too bright, but it is much better than the harmonic-shifted fit which is (very) flat, and sounds almost guitar-like.
– ydd
Commented Jul 13 at 2:37
• @ydd That makes sense. The accordion is a wonderful instrument for demonstrating this in person. An accordion with musette tuning does exactly this by definition, tuning each note both a few cents sharp and flat. (But also, if you you look at the FT of any single note played on an accordion - particularly on the bass side - you'll see a litter of sympathetic resonances that do not belong to the reed currently being played. It's hard to imagine the sound would be the same without them.)
– Slate
Commented Jul 13 at 13:21
• @Slate I really like this discussion; this has got me interested in characterizing instruments with respect to their deviation from the harmonics of the base note.
– ydd
Commented Jul 14 at 5:40