I'm doing some work with hermitian matrices. The initial work was done in matlab but I'm now doing some follow on work in python. I'm using numpy in python but I'm getting descrepencies between the eigenvalues reported in python and those in MatLab, can anyone tell me what's going wrong here?
I have more examples of this issue but a quick example is:
import numpy as np
mat = [[-1,1,-1],[1,-1,1],[-1,1,1]]
w,v = np.linalg.eig(mat)
gives
w = array([ -2.56155281e+00, 2.01878445e-16, 1.56155281e+00])
In MatLab -
mat = [-1,1,-1;1,-1,1;-1,1,1]
eig(mat)
ans =
-2.5616
0
1.5616
Is this MatLab being imprecise or Python throwing errors? I have many others that agree on the values, the disagreement is an exception on my full data set. Any help in explaining this issue would be great.
Thanks
Matalb
withformat long
:-2.561552812808829
,1.561552812808831
– Anton Protopopoveigh
instead ofeig
. – percusse