# Eigenvectors of numerical matrix

I have a large numerical matrix whose eigenvalues are all distinct. In the documentation for Eigenvectors it says:

For approximate numerical matrices m, the eigenvectors are normalized.

Eigenvectors with numeric eigenvalues are sorted in order of decreasing absolute value of their eigenvalues.

So from what I understand, Eigenvectors should give the same result every time. But in reality it gives different results, if I did some heavy calculation tasks in between to evaluations so that the autosaved evaluation results are erased. Why is that?

Here is the matrix causing the problem. Simply Import it into Mathematica and apply Eigenvectors. I'm using "10.0 for Microsoft Windows (32-bit) (June 30, 2014)".

omega = Import["Omega.m"]
Eigenvectors[omega]


Note that there must be lots of irrelevant calculation in between two evaluations in order to reproduce the problem. Sorry that I can't provide the code that I'm using but I think any heavy calculation will do. Or is there some way to turn off the automatic memoization?

• Can you provide your matrix and the code you use to get the eigenvalues? If not, can you reproduce the problem with an array of random numbers? – MarcoB Sep 1 '15 at 22:54
• @MarcoB I can provide the matrix and the code but it's kind of long so I'll put it a cloud drive. I haven't been able to reproduce this problem with randomly generated matrices. – arax Sep 1 '15 at 23:26
• Until your observations have been reproduced, please do not add the bugs tag to your question. – J. M. is away Sep 2 '15 at 0:49
• I haven't been able to reproduce the issue. But all the eigenvalues are on the order of 10^33... maybe there is some roundoff causing the order of the eigenvalues to change, which in turn changes the order of the eigenvectors? – bill s Sep 2 '15 at 1:02
• @bills I modified the matrix so that all its elements lie within [-10,10], but the problem is still there. I checked (omega.#/#)@[First@Eigenvectors@omega], and it turned out that it's not constant (with both positive and negative value) so it does seem to be a precision issue. Can I increase the precision without Rationalize everything? – arax Sep 2 '15 at 2:35

Here is a small trick. Let say you don't know the ordering of your eigenvetors.

m = RandomReal[1, {10, 10}];
m = m + Transpose[m];
es = Eigensystem[m];
es[[1]]


{9.46387, -2.07941, 1.87017, -1.69204, 1.6247, -1.00992, 0.835742, \ -0.786536, 0.669689, -0.463195}

Definitely not ordered. So you can force the order by Sort

es1 = Transpose[Sort[Transpose[es]]];
es1[[1]]


{-2.07941, -1.69204, -1.00992, -0.786536, -0.463195, 0.669689, \ 0.835742, 1.6247, 1.87017, 9.46387}

And it will assure the order of the eigenvectors as well.

Now if you get the feeling that the eigenvectors are not normalised, you can force that as well

es1 = Transpose[Sort[Transpose[es]/. {x_, y_List} :> {x, Normalize[y]}]];


As per comment by @bill, I have not been able to reproduce the problem. I did a trial run using the original matrix using the code below, and the figure values seem fixed. However there are a no. of eigenvectors with low probability of existence (see first figure), and might give rise to problems.

ListPlot[Eigenvectors[N[mat]], Frame -> True,
FrameLabel -> {Style["No.", Large, Bold],
Style["Occupation Amplitudes", Large, Bold],
Style["", Large, Bold]}, Ticks -> Automatic,
LabelStyle -> Directive[Black, Bold, Large]]


ListPlot[Eigenvalues[N[mat]], Frame -> True, Ticks -> Automatic,
LabelStyle -> Directive[Black, Bold, Large]]


To save your results, linking eigenvectors to the right ordered eigenvalues use:

omega = Import["Omega.m"]
{evals,evecs}:=Eigensystem[N[omega]]


Now the eigenvalues are associated with theire corresponding eigenvectors. After that I suggest to make sure youre eigenvectors are orthogonal. You can do a quick check by:

 MatrixForm[Chop[Table[evecs[[i]].evecs[[j]], {i, 1, Length[evecs]}, {j, 1,Length[evecs]}]]