Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello, This is the lab information. I need help with part C at the bottom. I need that explained to me in layman's terms. Just

Hello, This is the lab information. I need help with part C at the bottom. I need that explained to me in layman's terms. Just part C. I know it has something to do with the way vector b is defined. But I don't know how to explain it.

Thank you.

image text in transcribed

image text in transcribed

1. (a) Set n = 900. The commands below generate an n x n random matrix with integer entries between 0 and 9, an n x 1 vector z with all entries equal to 1, and an n 1 vector b given by the product Az. Enter the following commands: A = floor(10*rand (n)); = ones (n,1); b = A*z; Note: the command rand (n) generates a random n x n matrix with entries uniformly distributed between 0 and 1. We multiply these entries by 10 and then use the floor function to round them to the greatest integer less than or equal to. This gives a matrix with integer entries between 0 and 9. Since A was generated randomly, it is likely to be nonsingular. The system Ax = has a unique solution given by the vector z. (i) One could compute the solution in MATLAB using the \" operation or by com- puting A-1 and then multiplying A- times b. Let us compare these two compu- tational methods for both speed and accuracy. The inverse of the matrix A can be computed in MATLAB by typing inv (A). ne can use MATLAB tic and toc commands to measure the elapsed time for each computation. To do this, use the commands A\b; tic, x = toc inv (A)*b; tic, y = toc (Make sure the 'tic toc' are on the same line, for otherwise, the elapsed time will include the time it takes you to type the commands. If MATLAB gives a warning about the matrix being close to singular, generate the matrix A and the vector b again and repeat the computations. Which method is faster? (ii) 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. One way to do this is to compute the sum of the absolute values of the components of the difference of the two vectors, that is, E x; zi| and E lYi zi|. To evaluate these sums in MATLAB we use the following commands: sum(abs(x - z)) sum (abs (y - z)) Since we are finding the difference between the computed solution and the exact solution, the smaller number is associated with the method that is more accurate. Recall that x was computed using the "\" operation , while y was computed using the inverse. Which method produces the more accurate solution? (b) Repeat part (a) using n = 1800 and n = 3600. (c) Explain why the exact solution of the system Ax b is the vector z. 1. (a) Set n = 900. The commands below generate an n x n random matrix with integer entries between 0 and 9, an n x 1 vector z with all entries equal to 1, and an n 1 vector b given by the product Az. Enter the following commands: A = floor(10*rand (n)); = ones (n,1); b = A*z; Note: the command rand (n) generates a random n x n matrix with entries uniformly distributed between 0 and 1. We multiply these entries by 10 and then use the floor function to round them to the greatest integer less than or equal to. This gives a matrix with integer entries between 0 and 9. Since A was generated randomly, it is likely to be nonsingular. The system Ax = has a unique solution given by the vector z. (i) One could compute the solution in MATLAB using the \" operation or by com- puting A-1 and then multiplying A- times b. Let us compare these two compu- tational methods for both speed and accuracy. The inverse of the matrix A can be computed in MATLAB by typing inv (A). ne can use MATLAB tic and toc commands to measure the elapsed time for each computation. To do this, use the commands A\b; tic, x = toc inv (A)*b; tic, y = toc (Make sure the 'tic toc' are on the same line, for otherwise, the elapsed time will include the time it takes you to type the commands. If MATLAB gives a warning about the matrix being close to singular, generate the matrix A and the vector b again and repeat the computations. Which method is faster? (ii) 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. One way to do this is to compute the sum of the absolute values of the components of the difference of the two vectors, that is, E x; zi| and E lYi zi|. To evaluate these sums in MATLAB we use the following commands: sum(abs(x - z)) sum (abs (y - z)) Since we are finding the difference between the computed solution and the exact solution, the smaller number is associated with the method that is more accurate. Recall that x was computed using the "\" operation , while y was computed using the inverse. Which method produces the more accurate solution? (b) Repeat part (a) using n = 1800 and n = 3600. (c) Explain why the exact solution of the system Ax b is the vector z

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions