# [Numpy-discussion] Eigenvectors in Matlab vs. Numpy

Saket saketn@gmail....
Sun Jun 29 21:00:22 CDT 2008

```Hmm... so the relationship Ax = Lx should hold for every eigenvalue
and corresponding eigenvector of A, right? But, consider the first
eigenvalue,eigenvector pair:

for i,eval in enumerate(d):
print abs(numpy.dot(A,v[i]) - numpy.dot(eval,v[i])).max()
return

Outputs: 1.928

I thought maybe the ith eigenvector corresponds to a different (not
the ith) eigenvalue, but there doesn't seem to be any eigenvalue which
corresponds to the ith eigenvector such that the relationship holds...

Thanks again.

Saket

NOT AVAILABLE

blas_opt_info:
libraries = ['f77blas', 'cblas', 'atlas']
library_dirs = ['C:\\local\\lib\\yop\\sse2']
define_macros = [('ATLAS_INFO', '"\\"?.?.?\\""')]
language = c

NOT AVAILABLE

lapack_opt_info:
libraries = ['lapack', 'f77blas', 'cblas', 'atlas']
library_dirs = ['C:\\local\\lib\\yop\\sse2']
define_macros = [('ATLAS_INFO', '"\\"?.?.?\\""')]
language = f77

atlas_info:
libraries = ['lapack', 'f77blas', 'cblas', 'atlas']
library_dirs = ['C:\\local\\lib\\yop\\sse2']
language = f77

lapack_mkl_info:
NOT AVAILABLE

blas_mkl_info:
NOT AVAILABLE

atlas_blas_info:
libraries = ['f77blas', 'cblas', 'atlas']
library_dirs = ['C:\\local\\lib\\yop\\sse2']
language = c

mkl_info:
NOT AVAILABLE

On Sun, Jun 29, 2008 at 9:15 PM, Charles R Harris
<charlesr.harris@gmail.com> wrote:
>
>
> 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
>
>
>
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion@scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>
>
```