[Numpy-discussion] Eigenvectors in Matlab vs. Numpy
Charles R Harris
charlesr.harris@gmail....
Sun Jun 29 20:15:58 CDT 2008
On Sun, Jun 29, 2008 at 6:47 PM, Saket <saketn@gmail.com> wrote:
> 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.
>
Also note that the -1 eigenvalue has multiplicity 4. This means that any set
of orthogonal vectors spanning the same eigenspace will do for eigenvectors,
i.e., they aren't unique and roundoff error is likely to have a large effect
on what you end up with.
Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20080629/9f8fcac2/attachment.html
More information about the Numpy-discussion
mailing list