In practice, the vertical offsets from a line (polynomial, surface, hyperplane, etc.) are almost always minimized instead of the perpendicular offsets. This provides
a fitting function for the independent variable that estimates
for a given
(most often what an experimenter wants), allows uncertainties
of the data points along the
- and
-axes to be incorporated simply, and also provides a much simpler
analytic form for the fitting parameters than would be obtained using a fit based
on perpendicular offsets.
The residuals of the best-fit line for a set of points using unsquared perpendicular distances
of points
are given by
|
(1)
|
Since the perpendicular distance from a line to point
is given by
|
(2)
|
the function to be minimized is
|
(3)
|
Unfortunately, because the absolute value function does not have continuous derivatives, minimizing is not amenable to analytic solution. However, if the
square of the perpendicular distances
|
(4)
|
is minimized instead, the problem can be solved in closed form. is a minimum when
|
(5)
|
and
|
(6)
|
The former gives
|
(7)
| |||
|
(8)
|
and the latter
|
(9)
|
But
|
(10)
| |||
|
(11)
|
so (10) becomes
|
(12)
| |
|
(13)
| |
|
(14)
|
Plugging (◇) into (14) then gives
|
(15)
|
After a fair bit of algebra, the result is
|
(16)
|
So define
|
(17)
| |||
|
(18)
|
and the quadratic formula gives
|
(19)
|
with found using (◇). Note the rather unwieldy form of the
best-fit parameters in the formulation. In addition, minimizing
for a second- or higher-order polynomial
leads to polynomial equations having higher order, so this formulation cannot
be extended.