Mathematical method
In mathematics, least squares function approximation applies the principle of least squares to function approximation, by means of a weighted sum of other functions. The best approximation can be defined as that which minimizes the difference between the original function and the approximation; for a least-squares approach the quality of the approximation is measured in terms of the squared differences between the two.
Functional analysis
[edit]
A generalization to approximation of a data set is the approximation of a function by a sum of other functions, usually an orthogonal set:[1]

with the set of functions {
} an orthonormal set over the interval of interest, say [a, b]: see also Fejér's theorem. The coefficients {
} are selected to make the magnitude of the difference ||f − fn||2 as small as possible. For example, the magnitude, or norm, of a function g (x ) over the interval [a, b] can be defined by:[2]

where the ‘*’ denotes complex conjugate in the case of complex functions. The extension of Pythagoras' theorem in this manner leads to function spaces and the notion of Lebesgue measure, an idea of “space” more general than the original basis of Euclidean geometry. The {
} satisfy orthonormality relations:[3]

where δij is the Kronecker delta. Substituting function fn into these equations then leads to
the n-dimensional Pythagorean theorem:[4]

The coefficients {aj} making ||f − fn||2 as small as possible are found to be:[1]

The generalization of the n-dimensional Pythagorean theorem to infinite-dimensional real inner product spaces is known as Parseval's identity or Parseval's equation.[5] Particular examples of such a representation of a function are the Fourier series and the generalized Fourier series.
Using linear algebra
[edit]
It follows that one can find a "best" approximation of another function by minimizing the area between two functions, a continuous function
on
and a function
where
is a subspace of
:

all within the subspace
. Due to the frequent difficulty of evaluating integrands involving absolute value, one can instead define
![{\displaystyle \int _{a}^{b}[f(x)-g(x)]^{2}\,dx}](https://wikimedia.org/api/rest_v1/media/math/render/svg/0c1b945f1142ff48dc9110b80d95539993579c74)
as an adequate criterion for obtaining the least squares approximation, function
, of
with respect to the inner product space
.
As such,
or, equivalently,
, can thus be written in vector form:
![{\displaystyle \int _{a}^{b}[f(x)-g(x)]^{2}\,dx=\left\langle f-g,f-g\right\rangle =\lVert f-g\rVert ^{2}.}](https://wikimedia.org/api/rest_v1/media/math/render/svg/29cdda7506886c0e092566a8dd56b2c6004df2bd)
In other words, the least squares approximation of
is the function
closest to
in terms of the inner product
. Furthermore, this can be applied with a theorem:
- Let
be continuous on
, and let
be a finite-dimensional subspace of
. The least squares approximating function of
with respect to
is given by

- where
is an orthonormal basis for
.