In this problem, we will compare the speed of two methods for solving the system Ax = b when As 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 effciently 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 tie and toe command to measure the computation times A random matrix A, a vector b and the exact solution x of the system Ax = b have already been entered for you.
(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