least squares fitting proceeds by finding the sum of the squares of the vertical deviations
R2
of a set of n data points:
The condition for
R2
to be a minimum is that
for i=1, …, n. For a linear fit,
so
These lead to the equations
In matrix form,
so
The 2×2 matrix inverse is
so