Python eig for generalized eigenvalue does not return correct eigenvectors
You can see what's going on by looking at the shape of your output. Your a*v[:,0]
should give a vector, so why are you getting a 3x3 array? Answer: because you're not doing matrix multiplication, you're doing component-wise array multiplication.
IOW, you did
>>> a * v[:,0]array([[ -5.34928759e-02, 6.77083679e-10, -1.46171715e-06], [ -2.31417334e-10, 1.81432623e-02, 9.43440334e-06], [ 3.80252453e-07, 7.18074626e-06, 1.39685787e-02]])>>> w[0] * b * v[:,0]array([[-0.01805437+0.j, -0.01762974+0.j, -0.01781023+0.j], [ 0.00602559-0.j, 0.00603163+0.j, 0.00609548+0.j], [ 0.00463317-0.j, 0.00463941+0.j, 0.00470356+0.j]])
when you really wanted
>>> a.dot(v[:,0])array([-0.05349434, 0.0181527 , 0.01397614])>>> w[0] * b.dot(v[:,0])array([-0.05349434+0.j, 0.01815270+0.j, 0.01397614+0.j])
or
>>> matrix(a)*matrix(v[:,0]).Tmatrix([[-0.05349434], [ 0.0181527 ], [ 0.01397614]])>>> w[0]*matrix(b)*matrix(v[:,0]).Tmatrix([[-0.05349434+0.j], [ 0.01815270+0.j], [ 0.01397614+0.j]])