Skip to content

Start with the mathematical operation. A dense Hermitian eigensolver, an exact polynomial calculation and a time integrator certify different things. For each entry below, the linked example includes data or a result against which to check your own installation.

OperationTool and checkBoundary of the test
Small Hermitian sectorNumPy eigh, check eigenpairs against the full input matrixThe routine uses one triangle and assumes Hermiticity
Fredholm gap probabilityNumPy weighted quadrature matrix; SciPy special functions and independent ODEVary quadrature and tail cutoff independently
Singular Bethe vectorExact leading polynomial coefficient, then a normalized finite-vector residualRaw floating-point subtraction can lose the limiting vector
Finite open Toda with free end particlesVelocity Verlet, compared against QR evolution of open TodaPreserved energy alone cannot verify phase accuracy

Test the installation with a complex matrix

Section titled “Test the installation with a complex matrix”

The following test uses the 1.23 interface, checked with NumPy 1.23.5. The columns returned by the routine are orthonormal eigenvectors. An overall complex phase is arbitrary. NumPy 1.23, Parameters, Returns and Notes

import numpy as np
H = np.array([[1, 1j], [-1j, 1]])
assert np.allclose(H, H.conj().T)
E, V = np.linalg.eigh(H)
assert np.allclose(E, [0, 2])
assert np.linalg.norm(H @ V - V * E) < 1e-13
assert np.linalg.norm(V.conj().T @ V - np.eye(2)) < 1e-13

Change just the upper off-diagonal entry to 2i2i. With default lower-triangle input the solver can still return the original two eigenvalues. The matrix is now non-Hermitian; a full-input residual and the first assertion expose the changed problem. Compare subspace projectors if an eigenvalue is repeated. Quadrature and ODE example (Python) · Open Toda experiment (ZIP) · Finite-chain acceptance criteria

The two triangle choices give a quantitative failure control. With lower-triangle input the effective Hermitian matrix has off-diagonal magnitude one and eigenvalues 0,20,2. Choosing the upper triangle makes that magnitude two and gives −1,3-1,3. For either returned unitary eigenbasis VV, the Frobenius norm of the residual against the actual nonsymmetric input is one: the input and its Hermitian completion differ in one entry of magnitude one. Set a tolerance on this full-matrix residual only after checking the data type and energy units.

On 22 November 2026 this example ran with Python 3.10.16 and NumPy 1.23.5. The original full-input Frobenius residual was zero and its eigenvectors’ orthogonality defect was 3.2×10−163.2\times10^{-16}. The pinned NumPy release lists Python 3.8–3.11 support and uses a BSD license. Its eigensolver calls a Hermitian or real-symmetric LAPACK driver. Record the Python and NumPy versions and the linked numerical libraries when comparing your run with the example. NumPy 1.23.5 release and distribution metadata · NumPy 1.23 solver notes

  • NumPy Developers (2022). numpy.linalg.eigh. NumPy 1.23 Manual, Linear algebra, Hermitian eigenproblems. Source