Reverse software engineering of "\" in Matlab

120 Views Asked by At

23.3 Reverse software engineering of "". The following Matlab session records a sequence of tests of the elapsed times for various computations on a workstation manufactured in 1991. For each part, try to explain: (i) Why was this experiment carried out? (ii) Why did the result come out as it did? Your answers should refer to formulas from the text for flop counts. The Matlab queries help chol and help slash may help in your detective work.

%(a)
m = 200; Z = randn(m,m);
A = Z'*Z; b = randn(m,1);
tic; x = A\b; toc;
    elapsed_time = 1.0368
%(b)
tic; x = A\b; toc; 
    elapsed_time = 1.0303
%(c)
A2 = A; A2(m,1) = A2(m,1)/2;
tic; x = A2\b; toc;
    elapsed_time = 2.0361
%(d)
I = eye(m,m); emin = min(eig(A));
A3 = A - .9*emin*I;
tic; x = A3\b; toc;
    elapsed_time = 1.0362
%(e)
A4 = A - 1.1emin*I;
tic; x = A4\b; toc;
    elapsed_time = 2.9624
%(f)
A5 = triu(A);
tic; x = A5\b; toc;
    elapsed_time = 0.1261
%(g)
A6 = A5; A6(m,1) = A5(1,m);
tic; x = A6\b; toc;
    elapsed_time = 2.0012