Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

EXERCISE 5 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 fact 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 (900); x = ones (900,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. ) Compare the solutions from parts (a) and (b) with the exact solution x by computing norm(x rref - x) and norm(x_lu - 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

Automating Access Databases With Macros

Authors: Fish Davis

1st Edition

1797816349, 978-1797816340

More Books

Students also viewed these Databases questions