Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

Math 4445, 2022F, Project 1

Instructions:   Compress  the  MATLAB/Python les  and project  report  into  a  zip  (or  tar, gz) file  and upload to  Canvas .  The report must be typed, with requested MATLAB/Python codes and answers to all questions .  Note that this is not a group project and an honor code pledge must be included in the submitted report.

1.  Cholesky factorization for symmetric positive definite (SPD) matrices.

(a) Follow the algorithm in the lecture notes and complete the following function for Cholesky factorization. Include the code to your report (so that I can make comments if needed).

function L=cholesky(A)

%L=CHOLESKY(A)  -- Cholesky factorization

%  input

%     A     -     Symmetric positive definite matrix

%  output

%     L     -     Lower triangular matrix, A=L*L’

n=size(A,1);

L=zeros(n);

%  include your  code fragments here to  compute L matrix

...

end

(b)  Test your function with a small SPD matrix and make sure that L * L\  does reproduce A.  You may also compare your results with the MATLAB built-in function chol(). Include the results in your report.

(c)  Set up an exact formula for the number of multiplications/divisions of your code for an n x n SPD matrix.  Evaluate your formula and show that the operation count of Cholesky factorization is roughly half of the regular LU factorization.

2.  Backward and forward substitutions.

(a) Write two functions for forward and backward substitutions, respectively. Include these two functions in your report.

function x=forsub(L,b)

%X=FORSUB(L,b)  --  solve Lx=b using forward  substitution %  input

%     L     -     lower triangular matrix

%     b     -     right hand  side vector

%  output

%     x     -     solution vector

n=size(L,1);

%  include your  code fragments  in the following to perform % forward  substitution  . . .

end

function x=backsub(U,b)

%X=BACKSUB(L,b)  --  solve Ux=b using backward  substitution %  input

%     U     -     upper triangular matrix

%     b     -     right hand  side vector

%  output

%     x     -     solution vector

n=size(U,1);

%  include your  code fragments  in the following to perform % backward  substitution  . . .

end

(b)  Test your functions using small L and U . Attach results to the report.

3. Linear systems with SPD matrices. A Hilbert matrix is a square matrix with entries aij  =  for 1 s i, j s n. This matrix is known to be SPD and it can be generated by the MATLAB function hilb(n).  Write a script le (name it as hilbert .m) to solve Ax  = b  (by calling the functions that you developed in problems  1 and 2), where A is an n x n Hilbert matrix and b =A*ones(n,1), with n = 5, 10, 12, and 15. What do you observe? Does you code solve these linear systems accurately? Provide explanations. Include hilbert .m in your report.

4.  Suggest a method to compute the inverse of a SPD matrix A with the least possible operation counts. Suppose A is of size n x n, how many multiplications/divisions are required to invert it in your method?