Documentation

Eig3x3

Eig3x3 — closed-form eigendecomposition of real symmetric 3×3 matrices #

Pure Lean 4 eigendecomposition implementation of real symmetric 3×3 matrices over the Float type using Habera-Zilian's method [HZ25] for computing the eigenvalue vector and Eberly's non-iterative method [Ebe14] for computing the eigenvector matrix.

No Mathlib, no FFI bindings, native Lean, zero dependencies.

Why Habera-Zilian's Method? #

The algorithms in practical use for this problem are iterative. For example, LAPACK's symmetric eigensolvers (what NumPy, SciPy, and PyTorch call) tridiagonalize the matrix and iterate QR steps to convergence, which means loops, convergence tests, and running time dependent on input random variables.

The pre-existing closed-form alternatives, such as Cardano and Viète’s methods, avoid this computational cost but suffer in accuracy by evaluating the classical trigonometric cubic formula whose arccos near ±1 and subtractive discriminant lose precision when two eigenvalues are close.

Habera–Zilian [HZ25] remove this trade-off by proposing a closed-form alternative where numerically dangerous steps — using invariants from diagonal differences, computing the discriminant as a sum of squares, representing the angle as the arctan — are re-engineered. Performance is demonstrated to match iterative solvers at machine precision while still carrying the speed and determinism of a closed-form solution.

Provenance #

Deviations from the sources #

Validation (op-for-op float64 mirror vs numpy.linalg.eigh) #

Scope #

Complex Hermitian is currently out of scope but is in consideration for v2.

Note: Habera-Zilian [HZ25] report that Algorithm 8 for computing the discriminant exceeds its (lowest-order) forward-stability bound only for benchmarks with an ill-conditioned eigenbasis. However, this requires a regime with a non-orthogonal eigenvector matrix, which symmetric matrices never possess (κ₂ = 1). This package is scoped to real symmetric matrices, so the failing regime is out of scope by construction.

Usage #

import Eig3x3 publicly offers:

Unicode notation for common vector and matrix operations is offered with open scoped Eig3x3, including:

The eigenvector-only machinery (Eig3x3.Eigenvectors) is deliberately not public. Use eigendecomp.