(a) Write a well-commented MATLAB function program mysolvecheck with input a number n that makes a random n x n matrix A and a random vector b, solves the linear system Ax = b, calculates the scalar residual r= ||Ax - b||, and outputs that number as r. (b) Write a well-commented MATLAB script program that calls nysolvecheck 10 times each for n = 5, 10, 20, 40, 80, and 160, then records and averages the results and makes a log-log plot of the average r vs. n. Once your program is running correctly, increase the maximum n (by factors of 2) until the program stops running within 5 minutes. Turn in the plot and the two programs. (Do not print any large random matrices.)

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter13: Structures
Section: Chapter Questions
Problem 4PP
icon
Related questions
Question
100%

matlab

10.2 (a) Write a well-commented MATLAB function program mysolvecheck with input a number n that
makes a random n x n matrix A and a random vector b, solves the lincar system Ax = b,
calculates the scalar residual r= ||Ax – b||, and outputs that number as r.
(b) Write a well-commented MATLAB script program that calls mysolvecheck 10 times each for
n = 5, 10, 20, 40, 80, and 160, then records and averages the results and makes a log-log plot
of the average r vs. n. Once your program is running correctly, increase the maximum n (by
factors of 2) until the program stops running within 5 minutes.
Turn in the plot and the two programs. (Do not print any large random matrices.)
Transcribed Image Text:10.2 (a) Write a well-commented MATLAB function program mysolvecheck with input a number n that makes a random n x n matrix A and a random vector b, solves the lincar system Ax = b, calculates the scalar residual r= ||Ax – b||, and outputs that number as r. (b) Write a well-commented MATLAB script program that calls mysolvecheck 10 times each for n = 5, 10, 20, 40, 80, and 160, then records and averages the results and makes a log-log plot of the average r vs. n. Once your program is running correctly, increase the maximum n (by factors of 2) until the program stops running within 5 minutes. Turn in the plot and the two programs. (Do not print any large random matrices.)
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Use of XOR function
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr