% Script qralgH_test.m % test out qr iteration algorithm with and without hessenbeg form n = 100; % random eigenvalues; all made real. (cases 4,5,6,7) D = diag(randn(n,1)); V = randn(n); % Interesting results if orthogonal matrix here instead! Ak = V*D/V; % symmetric A: real eigenvalues (cases 1,2,3) % Ak = rand(n); % Ak = (Ak+Ak')/2; [dH,iterH] = qralgHt(Ak); [d,iter] = qralgt(Ak); [dH,idH] = sort(dH); [d,id] = sort(d); norm(d-dH) plot(1:length(Ak),iter(id),1:length(Ak),iterH(id),'--') xlabel('n'); ylabel('# of iterations'); legend('without','with','Location','NorthWest'); title('QR iterations with and without Hessenberg Form');