Write the recording as x[n], and write the approximation built from 15 harmonics of the fundamental you have assumed as
y[n] = 15∑k = 1 mk · cos( 2πk f0 n / fs + φk )
with mk and φk the magnitude and phase of harmonic k — lecture 2a's mk, and the bars in the fingerprint panel. The error is the average squared difference, as a fraction of the recording's own average square:
error = average of ( x[n] − y[n] )2average of x[n]2
So 0 means the 15 harmonics account for the recording exactly, and 1 means they account for none of it. It can exceed 1 if an amplitude is pushed well above its best value, because that adds energy the recording has not got.
Choosing the amplitudes. Each term can be rewritten as ak cos(2πk f0 n/fs) + bk sin(2πk f0 n/fs), with mk = √(ak2 + bk2). Once f0 is fixed, those 30 cosines and sines are fixed signals, and y[n] is a weighted sum of them with weights ak and bk. The error is then a quadratic function of the weights: a bowl with a single lowest point. The weights at that point can be found by solving 30 linear equations, with no searching. That is a least-squares fit, and the page does one every time f0 changes. “Best” on this page always means the least-squares value.
Where the Fourier coefficients come in. If the window held a whole number of periods, the 30 sinusoids would be orthogonal, the equations would separate, and each weight would be the Fourier coefficient formula (lecture 2b, with the integral over a period replaced by a sum over the samples) applied to that harmonic alone. A real window does not line up exactly, so the page solves the full set; on these recordings, fitting each harmonic on its own with the coefficient formula leaves an error within about 0.001 of this one.
The two plots differ only in what is held still. On the left, f0 is the variable and all the weights are re-solved at each candidate, so the curve answers “if I assumed this fundamental and then made the best least-squares fit, how much would be left over?” On the right, f0 stays where you set it and everything except one harmonic's amplitude stays at its least-squares value, so the curve answers “with everything else settled, what does moving this one amplitude cost?”