This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: MAE 107 Problem JDG-NA03 1.) Write a Matlab function cpucomp that will compare the required CPU time (on whatever platform is used) for solution of the n × 1 linear equation A x = b by means of the Matlab operations x=inv(A)*b and x=A \ b , for the case of a random (”forcing”) b= rand(n,1) . Your function should accept an n × n square matrix (A) as input and return the two times, say tinv and tbsl, along with the condition number of the matrix, in response to a function call of the form: [tinv, tbsl, c]=cpucomp(A) . Using the comment symbols %, include a brief preamble above the function definition stating what the function does and stating your name as author. (This preamble can then be displayed with the command help cpucomp . ) For a random forcing vector b= rand(n,1) , test your program on the matrices: i.) randomly rotated diagonal matrix , defined by: Q = orth(randn(n, n)); d = logspace(0,-10,n); A = Q*diag(d)*Q’; ii.) the Hilbert matrix , defined by A(i, j) =1/(i+j -1) , which may be constructed with for-loops., which may be constructed with for-loops....
View Full Document
- Winter '10
- Derivative, Elementary algebra, Bk, linear equation ax, Matlab function cpucomp, required CPU time