Let's start with a known set of eigenvalues and an orthogonal eigenvector basis.
D = diag([-6 -1 2 4 5]);
[V,R] = qr(randn(5));
A = V*D*V'; % note that V' = inv(V)
Now we will take the QR factorization and just reverse the factors.
[Q,R] = qr(A);
A = R*Q;
It turns out that this is a similarity transformation, so the eigenvalues are unchanged.
eig(A)
ans =
-6.000000000000001 -1.000000000000002 5.000000000000003 4.000000000000003 2.000000000000000
What's remarkable is that if we repeat the transformation many times, the process converges to .
for k = 1:15
[Q,R] = qr(A);
A = R*Q;
end
A
A =
-5.717280803318202 1.740123893057575 -0.037768561192074 -0.000000282468282 -0.000000000002784 1.740123893057576 4.713463869317748 -0.056979263094775 -0.000001252743229 0.000000000030252 -0.037768561192070 -0.056979263094776 4.003816933941975 0.000010798262392 0.000000000433793 -0.000000282468282 -0.000001252743229 0.000010798262392 1.999999997528164 -0.000087126218965 -0.000000000002784 0.000000000030252 0.000000000433792 -0.000087126218965 -0.999999997469674