Module for Least Squares Lines

Check out the new Numerical Analysis Projects page.

 

The formulas for linear least squares fitting were independently derived by German mathematician Johann Carl Friedrich Gauss  (1777-1855) and the French mathematician Adrien-Marie Legendre  (1752-1833).

 

Algorithm (Least Squares Line Fitting). To construct the least squares line  [Graphics:Images/LeastSquaresLineMod_gr_1.gif]  that fits the  n  data points  [Graphics:Images/LeastSquaresLineMod_gr_2.gif].
This is sometimes called the line of regression.

 

Mathematica Subroutine (Least Squares Line).

[Graphics:Images/LeastSquaresLineMod_gr_3.gif]

Example 1.  Find the standard "least squares line"  [Graphics:Images/LeastSquaresLineMod_gr_4.gif]  for the data points
[Graphics:Images/LeastSquaresLineMod_gr_5.gif].  
Use the subroutine Regression to find the line.  Compare with the line obtained with Mathematica's Fit procedure.
Solution 1.

 

Example 2.  Find the other "Least Squares Lines"  [Graphics:Images/LeastSquaresLineMod_gr_55.gif]  for the data points
[Graphics:Images/LeastSquaresLineMod_gr_56.gif].  
Use the subroutine Regression to find the line.
2 (a).  Use the computer to find the least squares lines  [Graphics:Images/LeastSquaresLineMod_gr_57.gif].   
2 (b).  Is it the same as the line we found in Example 1 ?   Why?
Solution 2.

 

Example 3.  Find the point of intersection of the two lines.
Solution 3.

 

What do you conjecture about the point of intersection of the two lines [Graphics:Images/LeastSquaresLineMod_gr_101.gif].  
Can you prove it ?

 

Philosophy.  What comes first the chicken or the egg ?  Which coordinate is more sacred, the abscissas or the ordinates.  We are always free to choose which variable is independent when we graph a line;  [Graphics:Images/LeastSquaresLineMod_gr_102.gif]  or   [Graphics:Images/LeastSquaresLineMod_gr_103.gif].  When you realize that two different "least squares lines" can be produced we are amazed.  What should we do ?  Which line should we use ?  You must decide a priori which variable is independent and which is dependent and then proceed. Exercise 3 asked you to think about the mathematics that is involved with this "paradox."

 

Example 4.  Computer derivation of the coefficients a and b for the "normal equations" for "Least Squares Lines"  [Graphics:Images/LeastSquaresLineMod_gr_104.gif].  
Solution 4.

 

Old Lab Project (Least Squares Lines  Least Squares Lines).  Internet hyperlinks to an old lab project.  

 

Research Experience for Undergraduates

Least Squares Lines  Least Squares Lines  Internet hyperlinks to web sites and a bibliography of articles.  

 

Downloads (Least Squares Lines Least Squares Lines).  
Download this Mathematica notebook.  

 

 

 

 

 

 

 

 

 

 

(c) John H. Mathews 2003