Search code examples
pythonnumpyscipyeigenvectoreigenvalue

How do I find out eigenvectors corresponding to a particular eigenvalue of a matrix?


How do I find out eigenvectors corresponding to a particular eigenvalue?

I have a stochastic matrix(P), one of the eigenvalues of which is 1. I need to find the eigenvector corresponding to the eigenvalue 1.

The scipy function scipy.linalg.eig returns the array of eigenvalues and eigenvectors.

D, V = scipy.linalg.eig(P)

Here D(array of values) and V(array of vectors) are both vectors.

One way is to do a search in D and extract the corresponding eigenvector in V. Is there an easier way?


Solution

  • If you are looking for one eigenvector corresponding to one eigenvalue, it could be much more efficient to use the scipy.sparse.linalg implementation of the eig function. It allows to look for a fixed number of eigenvectors and to shift the search around a specific value. You could do for instance :

    values, vectors = scipy.sparse.linalg.eigs(P, k=1, sigma=1)