Additional problem 1: Consider least squares approximation of a function f(x) = e^(-x) on the continuous interval 0,1 as a linear combination
f(x) ≈ ∑_(k=0)^n a_k g_k(x),
where we choose g_k(x) = x^k. Construct the resulting normal equations in the form Aa = b and solve them using CG. You should be able to derive analytic formulas for the entries a_ij and b_i, but you should then construct and solve the system Aa = b numerically. (To compute b_i analytically, you will need to use integration by parts.)
Plot your recovered approximation ∑_(k=0)^n a_k g_k(x) on the interval 0,1 for n=5,10.
Meanwhile, what do you notice about the convergence rate of CG as you take n much larger? Support your observation with numerical evidence / convergence plots. What could be causing this behavior? Please solve all parts and provide all appropriate MATLAB code. Thank you!