Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

loads/lab2.pdf Instructions: For the following three problems, follow the instructions in LAB 1 to create a diary text file. (a) Set n -700. The commands

image text in transcribed
loads/lab2.pdf Instructions: For the following three problems, follow the instructions in LAB 1 to create a diary text file. (a) Set n -700. The commands below generate an n x n random matrix with integer entries between 0 and 24, an n x 1 vector z with all entries equal to 1, and an n x 1 1. vector b given by the product Az. Enter the following commands A floor (25 rand (n)); z ones (a.) Note: the command rand (a) generates a random n X n matrix with entries uniformly distributed between 0 and 1. We multiply these entries by 25 and then use the floor function to round them to the greatest integer less than or equal to. This givesa matrix with integer entries between 0 and 24. Since A was genersted randomly, it is likely to be nonsingular. The system Ax b 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 ATl times b. Let us compare these two compu tational methods for both speed and accuracy. The inverse of the matrix Acan be computed in MATLAB by typing inv(A). One can use MATLAB tic and toc commands to measure the elapsed time for each computation. To do this, use the tic, y inv(A)b; 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 ives 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? (i) To compare the accuracy of the two methods, we can mensure 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, 21zi-1'l and lyi-til-To evaluate these sums in MATLAB we use the following commands: THIS CONTENT B sus (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. (b) Repeat part (a) using n-1400 and n-2800

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

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

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

How To Make A Database In Historical Studies

Authors: Tiago Luis Gil

1st Edition

3030782409, 978-3030782405

More Books

Students also viewed these Databases questions

Question

CA Qu . 3 2 Select the common word processing file extensions.

Answered: 1 week ago

Question

4. Devise an interview strategy from the interviewers point of view

Answered: 1 week ago