Example 4.  Compare the "discrete least squares approximation" and "continuous least squares approximation."
4 (a).  Use the function  ,  on the interval  .

Solution 4 (a).

``````

``````

``````

``````

Warning.  We must proceed with caution when using a least squares method because the linear system might be ill conditioned, i.e. the solution is highly sensitive to round off errors in the matrix and vector.  Let us investigate the situation for this example.

``````

``````

The condition number of the above system can be determined by Mathematica.

``````

``````

Fact.  Given the linear system  .  If     are input with machine precision then a bound for the error in the computed solution    is given by

where
is machine epsilon for the computer.  The computed solution    loses about    decimal digits of accuracy relative to precision of input.

``````

``````

Caveat.  Although Mathematica uses extended precision sixteen digit numbers, there is a possibility that the solution    might not have this much accuracy.

Remark.  When solving the continuous least squares approximation on the interval , the matrix of coefficients    is known to be a Hilbert matrix which is the classic example of an ill-conditioned matrix.

We are really done.

Aside.  We can calculate the coefficients    by directly setting up the matrix   vector .  This is just for fun !

``````

``````

This is the same as we obtained previously.

(c) John H. Mathews 2005