Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started