Question: Problem #1. Set n 200 and generate an n n matrix and two vectors in Rn (all having integer entries) via the following commands A

 Problem #1. Set n 200 and generate an n n matrix

Problem #1. Set n 200 and generate an n n matrix and two vectors in Rn (all having integer entries) via the following commands A = floor (10*rand(n)); b = sum(A,2); z = ones (n ,1); Since this matrix and these vectors are large, you want semicolons here to suppress the output. (a) The exact solution to Ax -b should be the vector z. Explain why. You can solve the linear system in MATLAB via either the backslash operation or by forming A-1b. What is the difference? Write a script to both time and compute the errors for each approach.1 Include the commands above and use tic toc as follows. tic; x = A\b; t1 = toc ; err1 max (abs (x-z)); disp(['time for backslash solve: ',num2str(t1)]) disp(['error for backslash solve: ',num2str(erri)]) tic; y inv (A) *b; t2 toc ; err2 = max (abs (y-z)); disp(['time for inverse A solve: ',num2str (t2)1) disp(['error for inverse A solve: ',num2str (err2)]) Which is faster and which has better error? Can you explain the results? (b) Repeat using n = 500 and n = 1000. Include your script, the output of your script, and comments on what you observe

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!