I have a question regarding the way how scipy.linalg.eig computes left and right eigenvectors. Maybe I misunderstood everything, but things seem not to be right to me...
From the beginning. To get eigenvalues and both eigenvectors I used the following:
ev, left_v, right_v = scipy.linalg.eig(A, left=True)
According to the manual, after setting left=True
while calling the function I should expect to get left eigenvectors as columns of left_v
where the ith column refers to the ith eigenvalue. However, the results were not what i anticipated so I did a simple check.
I computed right and left eigenvectors invoking the function twice (look here for details):
right_ev, right_v_2 = scipy.linalg.eig(A)
left_ev, left_v_2 = scipy.linalg.eig(A.T)
where columns ofleft_v_2
are eigenvectors associated with corresponding values in left_ev
.
Worth stressing that both right_ev_2
and left_ev_2
give the same eigenvalues, however they are in different order, which needs to be accounted for.
Comparing left_ev
and left_ev_2
(after reordering with respect to eigenvalues) one can quickly spot that the former is the conjugate of the latter and therefore left_ev
obtained from scipy.linalg.eig
with left=True
is not a valid left eigenvector.
Another check on the validity of the eigenvectors can be done based on the fact that for an arbitrary real square matrix left and right eigenvectors are biorthogonal, i.e.:
left_v.T.dot(right_v)
should give a diagonal matrix, but it doesn't,
until i change it to: left_v.T.conj().dot(right_v)
,
while:
left_v_2.T.dot(right_v_2)
gives an anticipated diagonal matrix.
Did anyone encounter similar problem before? Am I right with what I say? Is the sciPy manual a bit imprecise while describing eig
? Can you give any advice?
Many thanks!