2

I am getting a wrong eigen-vector (also checked by running multiple times to be sure) when i am using matrix.eig(). The matrix is:

1.2290 1.2168 2.8760 2.6370 2.2949 2.6402
1.2168 0.9476 2.5179 2.1737 1.9795 2.2828
2.8760 2.5179 8.8114 8.6530 7.3910 8.1058
2.6370 2.1737 8.6530 7.6366 6.9503 7.6743
2.2949 1.9795 7.3910 6.9503 6.2722 7.3441 
2.6402 2.2828 8.1058 7.6743 7.3441 7.6870

The function returns the eigen vectors:

-0.1698  0.6764  0.1442 -0.6929 -0.1069  0.0365
-0.1460  0.6478  0.1926  0.6898  0.0483 -0.2094
-0.5239  0.0780 -0.5236  0.1621 -0.2244  0.6072
-0.4906 -0.0758 -0.4573 -0.1279  0.2842 -0.6688
-0.4428 -0.2770  0.4307  0.0226 -0.6959 -0.2383
-0.4884 -0.1852  0.5228 -0.0312  0.6089  0.2865

Matlab gives the following eigen-vector for the same input:

0.1698 -0.6762 -0.1439  0.6931  0.1069  0.0365
0.1460 -0.6481 -0.1926 -0.6895 -0.0483 -0.2094
0.5237 -0.0780  0.5233 -0.1622  0.2238  0.6077
0.4907  0.0758  0.4577  0.1278 -0.2840 -0.6686
0.4425  0.2766 -0.4298 -0.0227  0.6968 -0.2384
0.4888  0.1854 -0.5236  0.0313 -0.6082  0.2857

The eigen-values for matlab and jama are matching but eigen-vectors the first 5 columns are reversed in sign and only the last column is accurate.

Is there any issue on the kind of input that Jama.Matrix.EigenvalueDecomposition.eig() accepts or any other problem with the same? Please tell me how i can fix the error. Thanks in advance.

demongolem
  • 9,474
  • 36
  • 90
  • 105
BHS
  • 991
  • 3
  • 12
  • 26

2 Answers2

9

There is no error here, both results are correct - as is any other scalar times the eigen vectors.

There are an infinite number of eigen vectors that work - its just convention that most software programs report the vectors that have length of one. That Jama reports eigen vectors equal to -1 times those of Matlab is probably just an artifact of the algorithm they used.

Vic E
  • 1,426
  • 1
  • 8
  • 4
  • please see carefully.... it is not scalar times another eigen vector all the columns except last have been inverted in sign.. last column for both is same... which is incorrect. – BHS Apr 06 '09 at 11:10
  • As I understand the conventions used for the result, each column is an eigenvector. So *one* of those has not been flipped in sign. Which makes each column still a valid eigenvector of norm 1. Where is the problem? – Varkhan Apr 06 '09 at 17:10
  • So, each of the eigen vectos may be flipped in sign and it's still safe. Then, the my doubt is cleared. Thanks.. – BHS Apr 07 '09 at 05:59
  • Thank you for this. I have been tearing my hair out trying to work out why I was getting flipped signs in Jama compared to Matlab. nice to know that it's irrelevant to the outcome – Will Faithfull Mar 13 '18 at 16:06
1

For a given matrix, the eigenvalues are unique, whose number equals the dimension of the matrix if plurality is considered. While the corresponding eigenvalues might be different because the vectors can scale according to a certain direction. In your post results, both JAVA and Matlab versions are correct.

Also, you could check the D matrix, where the eigenvalues come from. You could find they are the same.

Tau
  • 11
  • 1