detailed solution plz Cholesky factorization versus QR factorization. In this pr
ID: 3184924 • Letter: D
Question
detailed solution plz
Cholesky factorization versus QR factorization. In this problem we compare the accuracy of the two methods for solving a least-squares problem minimize |A-bll We take 10 b = | 1 + 10-k 1- 10-k A 10-k 0 10-k for k = 6, k 7 and k=8 (a) Write the norma equations, and solve them analytically (i.e., on paper, without (b) Solve the least-squares problem in MATLAB, for k 6, k 7 and k 8, using the (c) Repeat part (b), using the Cholesky factorization method, i.e., x (A'*A)CA'b using MATLAB) recommended method x - A. This method is based on the QR factorization (We assume that MATLAB recognizes that A A is symmetric positive definite, and uses the Cholesky factorization to solve ATAx ATb). Compare the results of this method with the results of parts (a) and (b) Remark. Type format long to make MATLAB display more than five digitsExplanation / Answer
SAVE THE FOLLOWING FUNCTION AND SCRIPT FILE IN MATLAB-
%% Cholesky Factorization
function [F]=cholesky(A,option)
if ~isequal(A,A'),
error('Input Matrix is not Symmetric');
end
if isPositiveDefinite(A),
[m,n]=size(A);
L=zeros(m,m);%Initialize to all zeros
row=1;col=1;
j=1;
for i=1:m,
a11=sqrt(A(1,1));
L(row,col)=a11;
if(m~=1), %Reached the last partition
L21=A(j+1:m,1)/a11;
L(row+1:end,col)=L21;
A=(A(j+1:m,j+1:m)-L21*L21');
[m,n]=size(A);
row=row+1;
col=col+1;
end
end
switch nargin
case 2
if strcmpi(option,'upper'),F=L';
else
if strcmpi(option,'lower'),F=L;
else error('Invalid option');
end
end
case 1
F=L;
otherwise
error('Not enough input arguments')
end
else
error('Given Matrix A is NOT Positive definite');
end
end
%% QR Factorization
A=sym(wilkinson(4));
R=qr(A)'
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.