the Least- Squares method


Introduction
This article describes an application of linear algebra,
to calculate the best fitting polynomial through a set of points.

Graphics-Explorer uses this method.

Look at the picture right:

you see the points (x1,y1)....(x5,y5).
Requested is the best fitting polynomial degree 2,
through these points.

"Best fitting" means in this case : the sum of the squares
of the deviations must be minimal.
Dotted lines show the deviations in the picture right.

the Least Squares method
Given are the points (x1,y1) , (x2,y2)...(xn , yn)

Requested:
a polynomial, degree m, y = c0 + c1x + c2x2 + ... + cmxm through these points with minimal deviations.

If the polynomial exactly crosses all points, if m+1 = n, than:

written as matrix:

If the polynomial does not exactly cross the points, there will be a difference vector:

The norm of this difference vector is the sum of all squared deviations.

So we look for the values of c , making || y - M . c || minimal.

This will be the case if the difference vector is perpendicular to the column space of M.
The inner product equals zero in this case.

Remarks
1.
Mt means the matrix M, reflected in the main diagonal.

If
than 2.
rule: ( A B)t = BtAt

3.
The inner product of two vectors a and b may be written as at.b

Example
Find the least-squares line through
points (0,1) (1,3) (2,4) en (3,4)

The line therefore is y = 1.5 + x