Least Squares Lines



    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).


Theorem (Least Squares Line Fitting). Given the  [Graphics:Images/LeastSqLineMod_gr_1.gif]  data points  [Graphics:Images/LeastSqLineMod_gr_2.gif],  the least squares line  [Graphics:Images/LeastSqLineMod_gr_3.gif]  that fits the points has coefficients a and b given by:

    [Graphics:Images/LeastSqLineMod_gr_5.gif] .

Proof  Least Squares Lines  Least Squares Lines  

Remark.  The least squares line is often times called the line of regression.


Computer Programs  Least Squares Lines  Least Squares Lines  


Mathematica Subroutine (Least Squares Line).


Example 1.  Find the standard "least squares line"  [Graphics:Images/LeastSqLineMod_gr_7.gif]  for the data points
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/LeastSqLineMod_gr_59.gif]  for the data points
Use the subroutine Regression to find the line.
2 (a).  Use the computer to find the least squares lines  [Graphics:Images/LeastSqLineMod_gr_61.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.


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/LeastSqLineMod_gr_109.gif]  or   [Graphics:Images/LeastSqLineMod_gr_110.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."


Another "Fit"

Theorem (Power Fit).
Given the  [Graphics:Images/LeastSqLineMod_gr_111.gif]  data points  [Graphics:Images/LeastSqLineMod_gr_112.gif],  the power curve  [Graphics:Images/LeastSqLineMod_gr_113.gif]  that fits the points has coefficients a given by:


Remark.  The case m = 1 is a line that passes through the origin.

Proof  Least Squares Lines  Least Squares Lines  


Mathematica Subroutine (Power Curve).


Example 4.  Find "modified least squares line" of the form   [Graphics:Images/LeastSqLineMod_gr_116.gif]  for the data points [Graphics:Images/LeastSqLineMod_gr_117.gif].  
Solution 4.


Application to Astronomy

    In 1601 the German astronomer Johannes Kepler  (1571-1630) formulated the third law of planetary motion  [Graphics:Images/LeastSqLineMod_gr_141.gif], where  [Graphics:Images/LeastSqLineMod_gr_142.gif]  is the distance to the sun measured in millions of kilometers, [Graphics:Images/LeastSqLineMod_gr_143.gif] is the orbital period measured in days, and  [Graphics:Images/LeastSqLineMod_gr_144.gif] is a constant.  The observed data pairs for the first four planets: Mercury, Venus, Earth, and Mars are [Graphics:Images/LeastSqLineMod_gr_145.gif].  


Example 5.  Find the power curve  [Graphics:Images/LeastSqLineMod_gr_146.gif]  for the data points [Graphics:Images/LeastSqLineMod_gr_147.gif].  
Solution 5.


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.  


Download this Mathematica Notebook Least Squares Lines


Return to Numerical Methods - Numerical Analysis




















(c) John H. Mathews 2004