# [SciPy-user] A comparison of Matlab's and SciPy's eig function for repeated eigenvalues

Nils Wagner nwagner at iam.uni-stuttgart.de
Thu Dec 7 04:19:14 CST 2006

```Hi all,

The eigenvectors associated with repeated eigenvalues are not uniquely
defined.
The eigenvectors returned by MATLAB's eig function are orthogonal with
respect
to A and B

[V,D] = eig(A,B)

V' * A * V = diag(a_i)
V' * B * V = diag(b_i)

And the eigenvalues differs with respect to the order.

How can I obtain "similar" results with SciPy ?

w, vr = linalg.eig(A,B)

dot(vr.T,dot(A,vr)) \ne diag(i_i)
dot(vr.T,dot(B,vr)) \ne diag(b_i)

I have attached  small test scripts for both, SciPy and MATLAB.

So, what is the difference between MATLAB's eig and SciPy's eig ?

Thanks in advance.

Nils

-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_multeig.py
Type: text/x-python
Size: 207 bytes
Desc: not available
Url : http://projects.scipy.org/pipermail/scipy-user/attachments/20061207/dcabc2a9/attachment.py
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_multeig.m
Type: application/m-file
Size: 251 bytes
Desc: not available
Url : http://projects.scipy.org/pipermail/scipy-user/attachments/20061207/dcabc2a9/attachment.bin
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: K1.mtx
Url: http://projects.scipy.org/pipermail/scipy-user/attachments/20061207/dcabc2a9/attachment.pl
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: M1.mtx
Url: http://projects.scipy.org/pipermail/scipy-user/attachments/20061207/dcabc2a9/attachment-0001.pl
```

More information about the SciPy-user mailing list