2

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?

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
arax
  • 1,831
  • 12
  • 16
  • 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 01 '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 01 '15 at 23:26
  • Until your observations have been reproduced, please do not add the [tag:bugs] tag to your question. – J. M.'s missing motivation Sep 02 '15 at 00: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 02 '15 at 01: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 02 '15 at 02:35
  • I don't think the quote from the docs implies that eigenvectors have to look the same every time. They are always ambiguous, as seen e.g. here. So I don't see any issue here. To get consistent results, just impose a sufficient number of additional conditions on the eigenvectors, such as normalization etc., as I mention in my answer linked above. – Jens Nov 01 '15 at 16:26

3 Answers3

2

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]}]];
Sumit
  • 15,912
  • 2
  • 31
  • 73
1

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]]

enter image description here

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

enter image description here

thils
  • 3,228
  • 2
  • 18
  • 35
0

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]}]]
MathNut
  • 47
  • 6