[Numpy-discussion] Eigenvectors in Matlab vs. Numpy

Saket saketn at gmail.com
Sun Jun 29 20:47:46 EDT 2008


Hi,

I'm having this weird problem when computing eigenvalues/vectors with
Numpy. I have the following symmetric matrix, B:

   -0.3462    0.6538    0.5385   -0.4615    0.6538   -0.3462   -0.3462   -0.3462
    0.6538   -0.3462    0.5385   -0.4615    0.6538   -0.3462   -0.3462   -0.3462
    0.5385    0.5385   -0.6154    0.3846    0.5385   -0.4615   -0.4615   -0.4615
   -0.4615   -0.4615    0.3846   -0.6154   -0.4615    0.5385    0.5385    0.5385
    0.6538    0.6538    0.5385   -0.4615   -0.3462   -0.3462   -0.3462   -0.3462
   -0.3462   -0.3462   -0.4615    0.5385   -0.3462   -0.3462    0.6538    0.6538
   -0.3462   -0.3462   -0.4615    0.5385   -0.3462    0.6538   -0.3462    0.6538
   -0.3462   -0.3462   -0.4615    0.5385   -0.3462    0.6538    0.6538   -0.3462

I compute the eigenvalues and eigenvectors of B using
numpy.linalg.eig(B). I get the following eigenvalues:

[  2.79128785e+00  -1.79128785e+00   1.64060486e-16  -3.07692308e-01
  -1.00000000e+00  -1.00000000e+00  -1.00000000e+00  -1.00000000e+00]

I do the same thing in Matlab and get the SAME eigenvalues. However,
my eigenVECTORS in Matlab versus numpy are different. It makes no
sense to me. In general, the following relationship should hold: Bx =
Lx, where B is my matrix, x is an eigenvector, and L is the
corresponding eigenvalue. For the eigenvectors that Matlab returns, I
have confirmed that the relationship does hold. But for the Numpy
eigenvectors, it doesn't!

Any idea why this might be happening? I did some computations myself
and it looks like the Matlab output is correct. Just seems like the
eigenvectors that Numpy is returning are wrong...

Thanks for any suggestions.

Saket



More information about the NumPy-Discussion mailing list