Wize University Linear Algebra Textbook > Least Squares Approximation
Least Squares Approximation
Popular Courses
Linear Algebra
University Study Guides
MATH 133
McGill University
MATH 1ZC3
McMaster University
Linear Algebra
General Course
MAT188H1
University of Toronto
Linear Algebra
University Study Guides
APSC 174
Queen's University
MAT133Y1
University of Toronto
MATH 1B03
McMaster University
ADM 1305
University of Ottawa
MATH 123
McGill University
MATH-1270
University of Windsor
MATH 1210
University of Manitoba
MATH-1250
University of Windsor
MATH 111
Queen's University
MATH 223
McGill University
MATH 1104
Carleton University
MATH 1300
University of Manitoba
MATH 232
Simon Fraser University
MAT 1302
University of Ottawa

0:00 / 0:00
Least Squares Approximation
Normal Equation
Given a linear system, we can write the normal equation:
Why is this useful?
The solution, , of the normal equation is a best possible approximation to a solution of .
That is, is the vector such that is as close as possible to .
Note: this result is usually used when the system is inconsistent, because otherwise we can find an exact solution!
Polynomials of Best Fit
Suppose we want to find a degree polynomial that "best fits" a set of points .
We'll define this polynomial of best fit to be:
Let .
Form the following matrix, just as we did when finding an interpolating polynomial:
Then, the coefficients of the polynomial are found by solving the normal equation:
Note: If the degree of the polynomial is smaller than the number of unique x-coordinates (of the given points), then the coefficients are uniquely determined.
Wize Tip
The special case of this result with is the line of best fit for a set of points.

0:00 / 0:00
Example: Least Squares for Linear Functions
Find the equation of the line that comes as close as possible to passing through the points: .
First, define the vector (look at each of the y-values):
Now fill in the matrix according to:
Note: Since we are looking for a line to approximate, we want a degree 1 polynomial, so .
Thus we have just 2 columns:
Now look at the normal equation to see what else we need to calculate:
Row reduce the augmented matrix for the system of normal equations:
Example: Least Squares for Polynomials
Find the equation of a quadratic polynomial that comes as close as possible to passing through the points: .
Note that there are only 2 distinct x-coordinates among the set of points, so a quadratic (degree 2) does NOT have degree strictly less than the number of unique x-coordinates. Therefore, we expect the answer NOT to be uniquely determined.
First, we look at all the y-coordinates to write:
Then we can form the matrix and calculate the pieces of the normal equation :
Therefore, the normal equation can be solved by row reducing:
Here we have a free variable for the third column, representing :
So for any choice of the parameter , the function would work.
For example, with we have: .
Interestingly, the case gives a linear function which approximates exactly as well (in terms of minimizing the squared distance from the given points):
Mark Yourself Question
- Grab a piece of paper and try this problem yourself.
- When you're done, check the "I have answered this question" box below.
- View the solution and report whether you got it right or wrong.
Practice: Least Squares Approximation
Find the cubic polynomial which best fits the data points .