Generalizing from a straight line (i.e., first degree polynomial) to a th degree polynomial
|
(1)
|
the residual is given by
|
(2)
|
The partial derivatives (again dropping superscripts) are
|
(3)
| |||
|
(4)
| |||
|
(5)
|
These lead to the equations
|
(6)
| |||
|
(7)
| |||
|
(8)
|
or, in matrix form
|
(9)
|
This is a Vandermonde matrix. We can also obtain the matrix for a least squares fit by writing
|
(10)
|
Premultiplying both sides by the transpose of the first matrix then gives
|
(11)
|
so
|
(12)
|
As before, given points
and fitting with polynomial coefficients
, ...,
gives
|
(13)
|
In matrix notation, the equation for a polynomial fit is given by
|
(14)
|
This can be solved by premultiplying by the transpose ,
|
(15)
|
This matrix equation can be solved numerically, or can be inverted directly if it is well formed, to yield the solution vector
|
(16)
|
Setting
in the above equations reproduces the linear solution.