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

Solution 1.

First, enter the data points.  This can be done as a list of lists or by using the Input menu and the Create Table submenu.

 

[Graphics:../Images/LeastSqLineMod_gr_9.gif]
[Graphics:../Images/LeastSqLineMod_gr_10.gif]

Using the Create Table submenu, we can get the following display to fill in the numbers.

[Graphics:../Images/LeastSqLineMod_gr_11.gif]
[Graphics:../Images/LeastSqLineMod_gr_12.gif]

When we fill in the numbers it will look like

 

[Graphics:../Images/LeastSqLineMod_gr_13.gif]
[Graphics:../Images/LeastSqLineMod_gr_14.gif]

After the data has been entered, compute the formulas for the least squares line.

[Graphics:../Images/LeastSqLineMod_gr_15.gif]



[Graphics:../Images/LeastSqLineMod_gr_16.gif]

[Graphics:../Images/LeastSqLineMod_gr_17.gif]
[Graphics:../Images/LeastSqLineMod_gr_18.gif]
[Graphics:../Images/LeastSqLineMod_gr_19.gif]
[Graphics:../Images/LeastSqLineMod_gr_20.gif]
[Graphics:../Images/LeastSqLineMod_gr_21.gif]


Let's see how the subroutine Regression  works.  The command for determining the abscissas is

 

[Graphics:../Images/LeastSqLineMod_gr_22.gif]
[Graphics:../Images/LeastSqLineMod_gr_23.gif]

[Graphics:../Images/LeastSqLineMod_gr_24.gif]

[Graphics:../Images/LeastSqLineMod_gr_25.gif]

[Graphics:../Images/LeastSqLineMod_gr_26.gif]

[Graphics:../Images/LeastSqLineMod_gr_27.gif]

The command for determining the ordinates is

 

[Graphics:../Images/LeastSqLineMod_gr_28.gif]

[Graphics:../Images/LeastSqLineMod_gr_29.gif]

We can add them up by using the selection operation  [Graphics:../Images/LeastSqLineMod_gr_30.gif]  and the summation found in the "BasisInput Palette" .

 

[Graphics:../Images/LeastSqLineMod_gr_31.gif]

[Graphics:../Images/LeastSqLineMod_gr_32.gif]

[Graphics:../Images/LeastSqLineMod_gr_33.gif]

[Graphics:../Images/LeastSqLineMod_gr_34.gif]

[Graphics:../Images/LeastSqLineMod_gr_35.gif]

[Graphics:../Images/LeastSqLineMod_gr_36.gif]

If you want to add up their squares then be careful using the power.  Sometimes extra parenthesis helps.

[Graphics:../Images/LeastSqLineMod_gr_37.gif]

[Graphics:../Images/LeastSqLineMod_gr_38.gif]

[Graphics:../Images/LeastSqLineMod_gr_39.gif]

[Graphics:../Images/LeastSqLineMod_gr_40.gif]

Let's peek at the linear system that was solved.

[Graphics:../Images/LeastSqLineMod_gr_41.gif]



[Graphics:../Images/LeastSqLineMod_gr_42.gif]
[Graphics:../Images/LeastSqLineMod_gr_43.gif]
[Graphics:../Images/LeastSqLineMod_gr_44.gif]
[Graphics:../Images/LeastSqLineMod_gr_45.gif]
[Graphics:../Images/LeastSqLineMod_gr_46.gif]
[Graphics:../Images/LeastSqLineMod_gr_47.gif]
[Graphics:../Images/LeastSqLineMod_gr_48.gif]
[Graphics:../Images/LeastSqLineMod_gr_49.gif]
[Graphics:../Images/LeastSqLineMod_gr_50.gif]
[Graphics:../Images/LeastSqLineMod_gr_51.gif]

Of course we want a graph.

[Graphics:../Images/LeastSqLineMod_gr_52.gif]


[Graphics:../Images/LeastSqLineMod_gr_53.gif]

[Graphics:../Images/LeastSqLineMod_gr_54.gif]

[Graphics:../Images/LeastSqLineMod_gr_55.gif]

[Graphics:../Images/LeastSqLineMod_gr_56.gif]

The sum of the residual's squared for this example is:

[Graphics:../Images/LeastSqLineMod_gr_57.gif]

[Graphics:../Images/LeastSqLineMod_gr_58.gif]

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

(c) John H. Mathews 2004