I am looking to solve a problem of the type: Aw = xBw
where x
is a scalar (eigenvalue), w
is an eigenvector, and A
and B
are symmetric, square numpy matrices of equal dimension. I should be able to find d
x/w pairs if A
and B
are d x d
. How would I solve this in numpy? I was looking in the Scipy docs and not finding anything like what I wanted.
The standard eigenvalue problem is defined by Ax = λx, where A is the given n by n matrix. The generalized eigenvalue problem is Ax = λBx where A and B are given n by n matrices and λ and x is wished to be determined. For historical reasons the pair A, B is called a pencil.
If A is an n × n matrix and λ is an eigenvalue with algebraic multiplicity k, then the set of generalized eigenvectors for λ consists of the nonzero elements of nullspace((A − λI)k). to find generalized eigenvector v2 = (0,1,0). 4. Finally, (A − I)3 = 0, so we get v3 = (1,0,0).
If X is the non-trivial column vector solution of the matrix equation AX = λX, where λ is a scalar, then X is the eigenvector of matrix A and the corresponding value of λ is the eigenvalue of matrix A. Suppose the matrix equation is written as A X – λ X = 0. Let I be the n × n identity matrix. A X – λ I X = 0.
For real symmetric or complex Hermitian dense matrices, you can use scipy.linalg.eigh()
to solve a generalized eigenvalue problem. To avoid extracting all the eigenvalues you can specify only the desired ones by using subset_by_index
:
from scipy.linalg import eigh
eigvals, eigvecs = eigh(A, B, eigvals_only=False, subset_by_index=[0, 1, 2])
One could use eigvals_only=True
to obtain only the eigenvalues.
Have you seen scipy.linalg.eig
? From the documentation:
Solve an ordinary or generalized eigenvalue problem of a square matrix.
This method have optional parameter b
:
scipy.linalg.eig(a, b=None, ...
b : (M, M) array_like, optional Right-hand side matrix in a generalized eigenvalue problem. Default is None, identity matrix is assumed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With