Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this exercise we will compare in MATLAB the speed of two methods for solving the system Ax = b when A is an invertible

image text in transcribed

In this exercise we will compare in MATLAB the speed of two methods for solving the system Ax = b when A is an invertible square matrix: computing the RREF and computing the LU factorization. Note that, although the number of operations for obtaining the LU factorization is the same as the gaussian elimination, the LU factorization has the advantage that once the matrix A is decomposed, the substitution step can be carried out efficiently for different values of b. Thus the LU factorization is certainly preferable when solving the system Ax = b with different values of b for the same A. We will use the MATLAB tic and toc command to measure the computation times. Enter A=rand (1000) ; x=ones (1000 , 1); b-A*x; Important: Be sure to use semicolon after each command so that matrices and vectors are not displayed. Do not print or include these large matrices and vectors in your lab write-up. (a) Solve Ax = b using the reduced row echelon form and store the solution in x.rref: tic; R= rref ( [A, b]); x-rref = R(: ,end); toc (make sure that all the commands are on the same line) (b) Solve Ax = b using the LU factorization as you did in EXERCISE 4(a)(b), and calculate the elapsed time using the tic toc commands. Store the solution in x.lu. Which method is faster? NOTE: Make sure you use semicolon; the only output should be the elapsed time. Also, don't forget that, when using tic toc all the commands should be in one line, so you should find L,U,P, solve for y, and solve for x.lu all on one line (c) Compare the solutions from parts (a) and (b) with the exact solution x by computing norm(x rref - x) and norm(xlu - x). How accurate are the solutions from parts (a) and (b)

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

Databases Illuminated

Authors: Catherine Ricardo

2nd Edition

1449606008, 978-1449606008

More Books

Students also viewed these Databases questions