About vl
, the eig
docstring says:
a.H vl[:,i] = w[i].conj() b.H vl[:,i]
Or, taking the conjugate transpose (i.e. Hermitian transpose) of both sides (which is what .H means), and assuming b
is the identity,
vl[:,i].H a = w[i] vl[:,i].H
So the rows of the conjugate transpose of vl
are the actual left eigenvectors of a
.
Numpy arrays don't actually have the .H attribute, so you must use .conj().T.
Here's a script to verify the calculation:
import numpy as np
from scipy.linalg import eig
# This only affects the printed output.
np.set_printoptions(precision=4)
a = np.array([[6, 2],
[-1, 4]])
w, vl, vr = eig(a, left=True)
print "eigenvalues:", w
print
# check the left eigenvectors one-by-one:
for k in range(a.shape[0]):
val = w[k]
# Use a slice to maintain shape; vec is a 2x1 array.
# That allows a meaningful transpose using .T.
vec = vl[:, k:k+1]
# rowvec is 1x2; it is the conjugate transpose of vec.
# This should be the left eigenvector.
rowvec = vec.conj().T
# Verify that rowvec is a left eigenvector
lhs = rowvec.dot(a)
rhs = val * rowvec
print "Compare", lhs, "to", rhs
print rowvec, "is",
if not np.allclose(lhs, rhs):
print "*NOT*",
print "a left eigenvector for eigenvalue", val
print
print "Matrix version:"
print "This"
print vl.conj().T.dot(a)
print "should equal this"
print np.diag(w).dot(vl.conj().T)
Output:
eigenvalues: [ 5.+1.j 5.-1.j]
Compare [[ 1.6330+2.4495j 4.0825+0.8165j]] to [[ 1.6330+2.4495j 4.0825+0.8165j]]
[[ 0.4082+0.4082j 0.8165-0.j ]] is a left eigenvector for eigenvalue (5+1j)
Compare [[ 1.6330-2.4495j 4.0825-0.8165j]] to [[ 1.6330-2.4495j 4.0825-0.8165j]]
[[ 0.4082-0.4082j 0.8165+0.j ]] is a left eigenvector for eigenvalue (5-1j)
Matrix version:
This
[[ 1.6330+2.4495j 4.0825+0.8165j]
[ 1.6330-2.4495j 4.0825-0.8165j]]
should equal this
[[ 1.6330+2.4495j 4.0825+0.8165j]
[ 1.6330-2.4495j 4.0825-0.8165j]]
Now, the eig
docstring also says in the description of the return values:
vl : double or complex ndarray
The normalized left eigenvector corresponding to the eigenvalue
``w[i]`` is the column v[:,i]. Only returned if ``left=True``.
Of shape ``(M, M)``.
and that is potentially misleading, since the conventional definition of a left eigenvector (e.g. http://mathworld.wolfram.com/LeftEigenvector.html or http://en.wikipedia.org/wiki/Eigenvalues_and_eigenvectors#Left_and_right_eigenvectors) is a row vector, so it is the conjugate transpose of the column of vl
that is actually the left eigenvector.