Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(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

(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 3a 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(A*x-b)).

(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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Management Systems

Authors: Mark L. Gillenson

2nd Edition

0470624701, 978-0470624708

More Books

Students also viewed these Databases questions