Question: Please provide a code. (20 pts.) As a general hint for this problem, you should debug your code using a small example where you know

Please provide a code. (20 pts.) As a general hint for thisPlease provide a code.

(20 pts.) As a general hint for this problem, you should debug your code using a small example where you know the answer (e.g. use the results from 3 a and 4a ). (a) Write a code to calculate the L and U in the the LU factorization of an nn matrix A (do not include pivoting). Your program should check for nearly zero pivot elements, print an error message, and cease operation if one is encountered. Run your code on a random matrix generated with A=rand(100,100). Confirm your factorization of A is correct by multiplying L and U together and comparing with A (hint, use norm(A-L*U)). (b) Assuming the L and U from above have been computed, write codes to perform the back substitutions required to solve Ax=LUx=b. Use your codes to solve the system Ax=b using the random matrix A from above and a randomly generated right hand side b. Confirm the correctness of the result by comparing Ax with b (hint, use norm(Axb)). (c) Using the codes form parts a and b above, solve a linear system generated by the rand (n,n) command with n=100. Report the number of seconds the code required to factor the matrix, and to perform the back substitutions (hint use the MATLAB commands tic and toc). Repeat this procedure for n=200,400,800,1600,3200. Comment on the increasing cost of the LU factorization and the back substitutions as the size of the matrix increases

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!