The method of least squares is a standard approach to the
approximate solution of overdetermined systems, i.e., sets of
equations in which there are more equations than unknowns.
"Least squares" means that the overall solution minimizes the
sum of the squares of the errors made in the results of every
single equation. The most important application is in data
fitting. The best fit in the least-squares sense minimizes the
sum of squared residuals, a residual being the difference
between an observed value and the fitted value provided by a
model. When the problem has substantial uncertainties in the
independent variable (the 'x' variable), then simple regression
and least squares methods have problems; in such cases, the
methodology required for fitting errors-in-variables models may
be considered instead of that for least squares. Least squares
problems fall into two categories: linear or ordinary least
squares and non-linear least squares, depending on whether or
not the residuals are linear in all unknowns.