Use MATLAB to generate random 4 4 matrices A and B. For each of the following, compute A1, A2, A3, and A4 as indicated and determine which of the matrices are equal (you can use MATLAB to test whether two matrices are equal by computing their difference): (a) A1 = A B, A2 = B A, A3 = (A_ B_ ) _, A4 = (B_ A_ ) _ (b) A1 = A_ B_, A2 = (A B) _, A3 = B_ A_, A4 = (B A) _ (c) A1 = inv(A B), A2 = inv(A) inv(B), A3 = inv(B A), A4 = inv(B) inv(A) (d) A1 = inv((A B) _ ), A2 = inv(A_ B_ ), A3 = inv(A_ ) inv(B_ ), A4 = (inv(A) inv(B)) _
Read more
Table of Contents
Textbook Solutions for Linear Algebra with Applications
Question
Set n = 200 and generate an n n matrix and two vectors in Rn, both having integer entries, by setting A = floor(10 rand(n)); b = sum(A_ ) _; z = ones(n, 1) (Since the matrix and vectors are large, we use semicolons to suppress the printout.) (a) The exact solution of the system Ax = b should be the vector z. Why? Explain. One could compute the solution in MATLAB using the \ operation or by computing A1 and then multiplying A1 times b. Let us compare these two computational methods for both speed and accuracy. One can use MATLABs tic and toc commands to measure the elapsed time for each computation. To do this, use the commands tic, x = A\b; toc tic, y = inv(A) b; toc Which method is faster? To compare the accuracy of the two methods, we can measure how close the computed solutions x and y are to the exact solution z. Do this with the commands max(abs(x z)) max(abs(y z)) Which method produces the most accurate solution? (b) Repeat part (a), using n = 500 and n = 1000.
Solution
The first step in solving 1 problem number 24 trying to solve the problem we have to refer to the textbook question: Set n = 200 and generate an n n matrix and two vectors in Rn, both having integer entries, by setting A = floor(10 rand(n)); b = sum(A_ ) _; z = ones(n, 1) (Since the matrix and vectors are large, we use semicolons to suppress the printout.) (a) The exact solution of the system Ax = b should be the vector z. Why? Explain. One could compute the solution in MATLAB using the \ operation or by computing A1 and then multiplying A1 times b. Let us compare these two computational methods for both speed and accuracy. One can use MATLABs tic and toc commands to measure the elapsed time for each computation. To do this, use the commands tic, x = A\b; toc tic, y = inv(A) b; toc Which method is faster? To compare the accuracy of the two methods, we can measure how close the computed solutions x and y are to the exact solution z. Do this with the commands max(abs(x z)) max(abs(y z)) Which method produces the most accurate solution? (b) Repeat part (a), using n = 500 and n = 1000.
From the textbook chapter Matrices and Systems of Equations you will find a few key concepts needed to solve this.
Visible to paid subscribers only
Step 3 of 7)Visible to paid subscribers only
full solution