Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

SciPy · Function

linalg.eigh

Solves standard or generalized eigenvalue problems for complex Hermitian or real symmetric matrices. It returns ascending eigenvalues and, unless disabled, corresponding normalized eigenvectors.

How it works

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.

Syntax

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)

Parameters

NameTypeDescription
a(M, M) array_likeComplex Hermitian or real symmetric matrix whose eigenvalues and eigenvectors are computed.
b(M, M) array_like, optionalOptional positive-definite matrix for the generalized eigenvalue problem.
lowerbool, optionalWhether to use the lower or upper triangular part of the matrices.
eigvals_onlybool, optionalIf true, compute only eigenvalues and omit eigenvectors.
overwrite_abool, optionalAllow overwriting the input matrix a to reduce memory usage.
overwrite_bbool, optionalAllow overwriting the input matrix b to reduce memory usage.
typeint, optionalSelect the generalized eigenvalue problem type: 1, 2, or 3.
check_finitebool, optionalCheck inputs for non-finite values before computation.
subset_by_index2-tuple, optionalInclusive zero-based index interval of eigenvalues to return.
subset_by_value2-tuple, optionalHalf-open eigenvalue interval used to select returned eigenvalues.
driverstr, optionalLAPACK driver to use for the eigensolver.

Returns

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.

Key points

  • Use this function for Hermitian or real-symmetric matrices, either as a standard eigenproblem or with a positive-definite generalized matrix.
  • The function always computes eigenvalues and can optionally compute eigenvectors.
  • For a generalized problem, the supplied b matrix must be positive definite.
  • Returned eigenvalues are ordered from smallest to largest, including when a subset is selected.
  • Eigenvectors are returned column-wise, so column i pairs with eigenvalue w[i].
  • Use driver to choose the underlying LAPACK algorithm when a specific solver is appropriate.

Example: Solve a symmetric eigenproblem

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 matrix

Computes the ascending eigenvalues and corresponding normalized eigenvectors of a real symmetric matrix.

When to use it

Standard eigenanalysis

Compute spectral values and directions for a real symmetric or complex Hermitian matrix.

Generalized eigenproblems

Solve problems expressed as a @ v = λ * b @ v with a positive-definite b.

Partial spectrum extraction

Extract only a selected range of eigenvalues by index or value.

Interview questions

QWhat problem does 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.

QWhat do the return values represent?

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.

QHow can computation be reduced or controlled?

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.eig
  • scipy.linalg.eigvalsh
  • scipy.linalg.schur
  • scipy.linalg.eigh_tridiagonal

Source: Eigh. Checked 2026-10-15.