CMPSC/Mathematics 451Final Exam–Part OneDue 11 November 2022Fall 2022You are to write a MATLAB (or Octave) function cgs2 that implementsclassical Gram-Schmidt with reorthogonalization. It...

Matlab


CMPSC/Mathematics 451 Final Exam–Part One Due 11 November 2022 Fall 2022 You are to write a MATLAB (or Octave) function cgs2 that implements classical Gram-Schmidt with reorthogonalization. It should have the first line function [Q,R] = cgs2(X) and should produce Q-R factorization by classical Gram-Schmidt with re- orthogonalization. The algorithm was taught in class in a lecture that I have duplicated in this folder. Here are two test problems that you are asked to use for the your function. The first is the 6×5 Läuchli matrix which can be generated by the command ≫ X = [ones(1, 5); sqrt(eps) ∗ eye(5)] For this example, display Q, R, ∥X −QR∥2 and ∥I5 −QTQ∥2. The second is a least squares function fitting problem to find a polyomial (written to conform the the MATLAB polyval function) p5(x) = a0x 5 + a1x 4 + a2x 3 + a3x 2 + a4x+ a5 to the function f(x) = ex on the interval [0, 1 2 (ln 2)]. For this problem complete the following steps 1. The mesh of points and the least squares problem can be generated the code d = 0.5 ∗ (log(2)) h = d/10; x = (0:h: d)′; b = exp(x); V = vander(X); X = V (:, 6: 11); 2. Use your cgs2 function to solve for a = (a0, a1, a2, a3, a4, a5) T . Note, be sure to treat b as an extra column of X as shown in class. Given a and the residual r = b−Xa in a manner comforming with how this algorithm is taught in class. 1 3. Perform the following test on your solution a. xx = (0: d/100: d)′; yy = polyval(a, xx); yexact = exp(xx); err = yexact− yy; err norm = norm(err, Inf); Give the value of err norm and plot xx and err against one another with approriate graph labels. You are welcome check any of your results using the MATLAB qr function, but that is not necessary. 2
Nov 09, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here