Example 4.  Find the continuous least squares polynomial of degree n=4 that approximates the function  [Graphics:Images/InverseMatrixMod_gr_188.gif]  over the interval  [Graphics:Images/InverseMatrixMod_gr_189.gif].  

Solution 4.

The set of functions is [Graphics:../Images/InverseMatrixMod_gr_190.gif].  

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


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

The inner product [Graphics:../Images/InverseMatrixMod_gr_193.gif]

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


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

Since  i  and  j  are positive integers, this can be simplified with the command

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


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

Therefore, the Gram matrix G is the 5×5 Hilbert matrix.

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


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

The inverse  [Graphics:../Images/InverseMatrixMod_gr_200.gif] is the matrix  M.

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


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

Enter the function  [Graphics:../Images/InverseMatrixMod_gr_203.gif],  and the set of functions  [Graphics:../Images/InverseMatrixMod_gr_204.gif], and compute [Graphics:../Images/InverseMatrixMod_gr_205.gif]  for   [Graphics:../Images/InverseMatrixMod_gr_206.gif], and write down the linear system GC = Y to be solved.

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



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


Solve the linear system for the coefficients [Graphics:../Images/InverseMatrixMod_gr_210.gif] using  [Graphics:../Images/InverseMatrixMod_gr_211.gif] and the computation  [Graphics:../Images/InverseMatrixMod_gr_212.gif].

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


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

Construct the polynomial  p[x].  The coefficients are stored in the array  c  and the elements are [Graphics:../Images/InverseMatrixMod_gr_215.gif].

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



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

We are done.

We can graph the polynomial, this is just for fun !

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


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

[Graphics:../Images/InverseMatrixMod_gr_220.gif]
[Graphics:../Images/InverseMatrixMod_gr_221.gif]
[Graphics:../Images/InverseMatrixMod_gr_222.gif]


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


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

[Graphics:../Images/InverseMatrixMod_gr_225.gif]
[Graphics:../Images/InverseMatrixMod_gr_226.gif]
[Graphics:../Images/InverseMatrixMod_gr_227.gif]


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


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

[Graphics:../Images/InverseMatrixMod_gr_230.gif]
[Graphics:../Images/InverseMatrixMod_gr_231.gif]

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

(c) John H. Mathews 2004