Set n = 200 and generate an n n matrix and two vectors in Rn, both having integer | StudySoup

Textbook Solutions for Linear Algebra with Applications

Chapter 1 Problem 2

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

Step 1 of 3)

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.

Step 2 of 7)

Visible to paid subscribers only

Step 3 of 7)

Visible to paid subscribers only

Subscribe to view the
full solution

Title Linear Algebra with Applications 8 
Author Steve Leon
ISBN 9780136009290

Set n = 200 and generate an n n matrix and two vectors in Rn, both having integer

Chapter 1 textbook questions

×

Login

Organize all study tools for free

Or continue with
×

Register

Sign up for access to all content on our site!

Or continue with

Or login if you already have an account

×

Reset password

If you have an active account we’ll send you an e-mail for password recovery

Or login if you have your password back