We saw that the time t required to solve a banded matrix of size n × n with a bandwidth p = q scales like t ∼ np2. In this problem, we will explore the ability of MATLAB’s internal solver to handle large, banded matrices. Write a MATLAB program that determines the time required to solve a 500 × 500 system of the form Ax = b using the slash command for values of p = q from 1:499. To check that you have the right matrix, you should compute the number of non-zero elements in your matrix using the find and size functions in MATLAB. To get the time required for a given value of p in your program, you use the command tic to start to clock before you solve the matrix system and toc to stop the clock after you solve the matrix system. If you write t = toc, the value of the time will be stored in the variable t. The non-zero elements of the matrix A and the 500 × 1 forcing vector b should be randomly chosen for each value of p using the rand function in MATLAB. Make a plot of the number of non-zero elements in your matrix versus the value of p and make a log–log plot of the time required for the matrix solution versus the value of p. State how you would expect the slope of the log–log plot to look for Gauss elimination and whether the time required for the MATLAB solution method scales faster, the same, or slower than Gauss elimination with a banded solver.
#Sales Offer!| Get upto 25% Off: