Compute matrix eigenpairs
Analyze a square system's modal behavior.
SciPy · Function
Solves ordinary or generalized eigenvalue problems for square matrices. It returns eigenvalues and, optionally, left and normalized right eigenvectors.
eig solves the ordinary problem A v = w v or, when b is supplied, the generalized problem A v = w B v. It can return normalized right eigenvectors, optional left eigenvectors, or homogeneous eigenvalue coordinates, while flags control input checking and possible in-place workspace use.
scipy.linalg.eig(a, b=None, left=False, right=True, overwrite_a=False, overwrite_b=False, check_finite=True, homogeneous_eigvals=False)| Name | Type | Description |
|---|---|---|
a | (M, M) array_like | Square input matrix for the eigenvalue problem. |
b | (M, M) array_like | Optional right-hand-side square matrix for the generalized problem. |
left | bool, optional | Whether to compute left eigenvectors. |
right | bool, optional | Whether to compute right eigenvectors. |
overwrite_a | bool, optional | Allow overwriting a when possible to reduce workspace use. |
overwrite_b | bool, optional | Allow overwriting b when possible to reduce workspace use. |
check_finite | bool, optional | Check inputs for finite values before computation. |
homogeneous_eigvals | bool, optional | Return generalized eigenvalues in homogeneous coordinates. |
Depending on left and right, returns the eigenvalues w, optional left eigenvectors vl, and optional normalized right eigenvectors vr; w uses homogeneous coordinates when homogeneous_eigvals=True.
eig for square-matrix eigenproblems, either ordinary or generalized.vr and is normalized.vl.b to define the second matrix in the generalized equation.left=True.left=True are not normalized, unlike the right eigenvectors.import numpy as np
from scipy.linalg import eig
A = np.array([[1.0, 2.0], [2.0, 1.0]])
w, vr = eig(A)
print(w)
print(vr)Computes the eigenvalues and normalized right eigenvectors of a real square matrix.
Analyze a square system's modal behavior.
Solve A v = w B v for two square matrices.
Obtain dual vectors for non-Hermitian matrices.
Represent potentially infinite generalized eigenvalues safely.
scipy.linalg.eig solve?It solves an ordinary or generalized eigenvalue problem. With only a, it finds w and vectors satisfying A v = w v; with b, it solves A v = w B v.
Follow-up: How are left eigenvectors characterized? They satisfy A.H vl[:, i] = w[i].conj() B.H vl[:, i], and they are returned only when left=True.
By default, the function returns eigenvalues and normalized right eigenvectors. The eigenvector associated with w[i] is the column vr[:, i].
Follow-up: What changes when right=False? The right-eigenvector array is omitted, so the return structure contains only the requested eigenvalue and left-eigenvector results.
b and homogeneous_eigvals used for?b is the right-hand-side matrix for a generalized problem and must have shape (M, M). homogeneous_eigvals=True instead returns eigenvalues in homogeneous coordinates, represented with an extra leading dimension.
Follow-up: Why use homogeneous coordinates? They allow generalized eigenvalues that may otherwise be infinite to be represented without converting them to ordinary finite scalars.
scipy.linalg.eighscipy.linalg.eigvalsscipy.linalg.eigvalsh