This is Matlab question of Linear Algebra, and it should be solved by using Matl
ID: 3281996 • Letter: T
Question
This is Matlab question of Linear Algebra, and it should be solved by using Matlab. Need the code and script of the two question.
Matlab Exercises The condition number of a matrix A, defined by cond A All2A-12, allows one to estimate the accuracy of a computed solution of a system Ax = b. If the entries of A and b are accurate to about r significant digits, and cond A ~ k, then the computed solution of Ax = b should usually be accurate to at least r-k significant digits. Solve the following two problems: Compute the Hilbert matrix H of order k- 5 and k 12 using the hilb command. -For k = 5, solve the system Hx b for a suitable b to find the last column of the inverse of H. Use the backslash command. To find a suitable b think of the solution as x - H-1b. - For k- 5 and k 12, solve the system Hx - y using the backslash command, where y is generated by applying H to a random vector x*, ie., y-Hx". Compute the 2-norm of the difference between x* and x, i.e., ? Hlx*-x112 and print ? to the screen. Print also the condition number (command: cond CH)) of H to the screen. Describe what you observe. Find the determinant (command: det (A)) and the condition number (command: cond (A)) of the Hilbert matrix H of order k (command: hilb(k)), for k- 1,2,...,10. Plot the determinant and the condition number as a function of k using a logarithmic scale for the vertical axis.Explanation / Answer
Sol for Ques 1(a)
k = 5;
b = eye(k);
H = hilb(k);
x = H;
lastcol = x(1:k,k);
disp(lastcol);
Sol for Ques 1(b)
p = [5 12];
for i = 1:numel(p)
k = p(i);
H = hilb(k);
x1 = randn(k,1);
y = H*x1;
x = Hy;
delta = norm(x1 - x);
fprintf('for k = %d : ',k);
fprintf('The value of delta is %.6f The value of cond(H) is %.6f ',delta,cond(H));
end
Sol for Ques 2:
deter = [];
condno = [];
for k = 1:10
H = hilb(k);
deter(k) = det(H);
condno(k) = cond(H);
end
k = linspace(1,10,10);
semilogy(k,deter,k,condno);
legend('Determinant','Condition No');
xlabel('Values of k');
ylabel('y');
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.