Example 3. Find the
"least squares cubic" that for the four data points
.
Solution 3.
(a). Write down the linear system AC = B to be solved.
(b). Construct the Cholesky factorization of matrix A.
Invoke the subroutine Cholesky.
Verify the factorization.
(c). Solve the linear system
for the coefficients
using our ForeSub[n] and [BackSub[n] subroutines.
First, solve the lower-triangular system LY = B for Y.
Verify that LY = B.
Second, solve the upper-triangular system UX = Y for X.
Verify that UX = Y.
Therefore X is the solution to LUX =
B. and hence AX = B
And we can verify that it is the solution.
Now use the solution to X make the
coefficients
.
(d). Construct the
polynomial p[x]. The
coefficients are stored in the array c and
the elements are
.
Of course we could do all this work in two lines by using
Mathematica's built in
procedure.
We are done.
We can graph the polynomial, this is just for fun !
![[Graphics:../Images/CholeskyMod_gr_229.gif]](../Images/CholeskyMod_gr_229.gif)
(c) John H. Mathews 2004