Standard eigenanalysis
Compute spectral values and directions for a real symmetric or complex Hermitian matrix.
SciPy · Function
Solves standard or generalized eigenvalue problems for complex Hermitian or real symmetric matrices. It returns ascending eigenvalues and, unless disabled, corresponding normalized eigenvectors.
eigh solves either a standard problem, a @ v = w * v, or a generalized problem, a @ v = w * b @ v when b is supplied. It returns eigenvalues in ascending order and, unless disabled, eigenvectors as columns; for generalized problems, b must be positive definite.
scipy.linalg.eigh(a, b=None, *, lower=True, eigvals_only=False, overwrite_a=False, overwrite_b=False, type=1, check_finite=True, subset_by_index=None, subset_by_value=None, driver=None)| Name | Type | Description |
|---|---|---|
a | (M, M) array_like | Complex Hermitian or real symmetric matrix whose eigenvalues and eigenvectors are computed. |
b | (M, M) array_like, optional | Optional positive-definite matrix for the generalized eigenvalue problem. |
lower | bool, optional | Whether to use the lower or upper triangular part of the matrices. |
eigvals_only | bool, optional | If true, compute only eigenvalues and omit eigenvectors. |
overwrite_a | bool, optional | Allow overwriting the input matrix a to reduce memory usage. |
overwrite_b | bool, optional | Allow overwriting the input matrix b to reduce memory usage. |
type | int, optional | Select the generalized eigenvalue problem type: 1, 2, or 3. |
check_finite | bool, optional | Check inputs for non-finite values before computation. |
subset_by_index | 2-tuple, optional | Inclusive zero-based index interval of eigenvalues to return. |
subset_by_value | 2-tuple, optional | Half-open eigenvalue interval used to select returned eigenvalues. |
driver | str, optional | LAPACK driver to use for the eigensolver. |
w: an (N,) ndarray of selected eigenvalues in ascending order. v: an (M, N) ndarray of normalized eigenvectors, where column i corresponds to w[i]; it is omitted when eigvals_only=True.
b matrix must be positive definite.i pairs with eigenvalue w[i].driver to choose the underlying LAPACK algorithm when a specific solver is appropriate.import numpy as np
from scipy.linalg import eigh
A = np.array([[2.0, 1.0], [1.0, 2.0]])
w, v = eigh(A)
print(w) # [1. 3.]
print(v.T @ A @ v) # diagonal eigenvalue matrixComputes the ascending eigenvalues and corresponding normalized eigenvectors of a real symmetric matrix.
Compute spectral values and directions for a real symmetric or complex Hermitian matrix.
Solve problems expressed as a @ v = λ * b @ v with a positive-definite b.
Extract only a selected range of eigenvalues by index or value.
scipy.linalg.eigh solve?It solves a standard Hermitian or real-symmetric eigenproblem, or a generalized problem when b is provided. The generalized relation is a @ vi = λ * b @ vi, and b must be positive definite.
Follow-up: How are the results normalized? The generalized eigenvectors satisfy normalization with respect to b, so their b-weighted inner products are orthonormal.
The first returned array contains selected eigenvalues in ascending order. The second contains normalized eigenvectors as columns, with column i corresponding to eigenvalue w[i].
Follow-up: How can only part of the spectrum be requested? Use subset_by_index for an inclusive index range or subset_by_value for an eigenvalue interval.
eigvals_only=True skips eigenvector computation and returns only eigenvalues. The driver parameter selects a LAPACK routine; standard and generalized problems have different valid driver sets.
Follow-up: Which driver is the default for standard problems? The documentation identifies evr as the default standard driver when no generalized matrix is supplied.
scipy.linalg.eigscipy.linalg.eigvalshscipy.linalg.schurscipy.linalg.eigh_tridiagonal