nstart = 11;
nmax = 50;
data = zeros(nmax-nstart+1,4);
for n=nstart:nstart+nmax,
[tlu,tqr,tschur,tsvd] = cost(5*n);
data(n-nstart+1,1) = tlu;
data(n-nstart+1,2) = tqr;
data(n-nstart+1,3) = tschur;
data(n-nstart+1,4) = tsvd;
end;
en = linspace( 5*nstart, 5*(nmax+nstart)+nmax, 6*nmax-5*nstart );
n = (nstart:nstart+nmax);
A = [ (5*n).^3', (5*n).^2', 5*n', ones(size(n))' ];
lufit = A\data(:,1);
qrfit = A\data(:,2);
schurfit = A\data(:,3);
svdfit = A\data(:,4);
lun = polyval( lufit, en );
qrn = polyval( qrfit, en );
schurn = polyval( schurfit, en );
svdn = polyval( svdfit, en );
figure(1), plot( en, lun, 'k-', 5*n, data(n-nstart+1,1), 'k+' )
figure(2), plot( en, qrn, 'k-', 5*n, data(n-nstart+1,2), 'k+' )
figure(3), plot( en, schurn, 'k-', 5*n, data(n-nstart+1,3), 'k+' )
figure(4), plot( en, svdn, 'k-', 5*n, data(n-nstart+1,4), 'k+' )
figure(5), semilogy( en, lun, 'k-', 5*n, data(n-nstart+1,1), 'k+', ...
en, qrn, 'k--', 5*n, data(n-nstart+1,2), 'ko', ...
en, schurn, 'k-.', 5*n, data(n-nstart+1,3), 'kx', ...
en, svdn, 'k:', 5*n, data(n-nstart+1,4), 'k.' )...
, axis( [5*nstart,nstart+6*nmax,10^(-3),2*10^(0)]);
set(gca,'fontsize',16);
xlabel('n','fontsize',16);
ylabel('cpu time (seconds)','fontsize',16);