Definition (Lanczos process). For a Hermitian matrix \mathbf{A} and starting vector \mathbf{b}, build a graded orthonormal basis \mathbf{Q}_k of \mathcal{K}_k(\mathbf{A},\mathbf{b}). The compression \mathbf{T}_k=\mathbf{Q}_k^{\mathsf{H}}\mathbf{A}\mathbf{Q}_k is Hermitian tridiagonal. In exact arithmetic, each new basis vector can be generated with a three-term recurrence. Breakdown means the next Krylov direction is zero; the generated space is then invariant. Reorthogonalization changes the concrete recurrence and its rounded behavior.
Lanczos process
Build a Krylov basis and a tridiagonal compression of a symmetric operator. This shared factorization supports linear solves, spectral approximation, matrix functions, and quadrature. Its task placements all link to this one mathematical construction.
Implementation guides
Implementations
Ordinary Lanczos
The guarded three-term recurrence with a matrix-free operator and exact vector operations.
Models: Exact arithmetic · BLAS + matvec; Standard rounding · BLAS + matvec; Standard rounding · stored scalar
Lanczos with full reorthogonalization
Orthogonalize new basis vectors against the stored basis.
Lanczos with selective reorthogonalization
Reorthogonalize selected components rather than sweeping the full basis.
Definition
Mathematical guarantees
Theorem (Tridiagonal compression). Let \mathbf{A} be Hermitian and let \mathbf{Q}_k be a graded Krylov basis. Then \mathbf{Q}_k^{\mathsf{H}}\mathbf{A}\mathbf{Q}_k is tridiagonal. This structure is the mathematical reason that Lanczos can use a short recurrence.
Lean statement and details
NLAlib.IsGradedKrylovBasis.isTridiagonal.{u_1, u_2} {𝕜 : Type u_1} [RCLike 𝕜] {n : Type u_2}
[Fintype n] [DecidableEq n] {A : Matrix n n 𝕜} {b : n → 𝕜} {q : ℕ} {Q : Matrix n (Fin q) 𝕜}
(hQ : IsGradedKrylovBasis A b Q) (hA : A.IsHermitian) : IsTridiagonal (Qᴴ * A * Q)Uses and composed algorithms
Lanczos is a shared process. Its compression supports several tasks; evaluating a function or averaging random probes adds further algorithmic steps, represented by their own pages.
Lanczos matrix-function approximation
Run Lanczos, evaluate f on the small tridiagonal matrix, and lift the result to approximate f(\mathbf{A})\mathbf{b}.
Lanczos quadrature
Use the Lanczos compression to approximate a quadratic form \mathbf{b}^{\mathsf{T}}f(\mathbf{A})\mathbf{b}.
Stochastic Lanczos quadrature
Average Lanczos-based quadrature over random probes to estimate spectral quantities.
MINRES
Minimize the residual over a Krylov space for a symmetric system.
Further results
Theorem (Kaniel–Paige–Saad).
for Hermitian \mathbf{A} whose eigenvalues other than \lambda_0 = \lambda_0(\mathbf{A}) lie in [a, c], a < c < \lambda_0, a vector \mathbf{b} with a component in the top eigenspace E_{\lambda_0}, and the largest Ritz value \theta_0 of \mathcal{K}_{q+1}(\mathbf{A}, \mathbf{b}) (the largest eigenvalue of \mathbf{Q}^{\mathsf{H}}\mathbf{A}\mathbf{Q} for \mathbf{Q} with orthonormal columns spanning it), \lambda_0 - \theta_0 \le 4(\lambda_0 - a)\tan^2\angle(\mathbf{b}, E_{\lambda_0}) \Bigl(\frac{\sqrt{\lambda_0 - a} - \sqrt{\lambda_0 - c}}{\sqrt{\lambda_0 - a} + \sqrt{\lambda_0 - c}}\Bigr)^{2q}\,, \tan^2\angle(\mathbf{b}, E_{\lambda_0}) the ratio \mu_{\mathbf{A},\mathbf{b}}(\mathbb{R}\setminus\{\lambda_0\})/ \mu_{\mathbf{A},\mathbf{b}}(\{\lambda_0\}) of the spectral measure. The proof gives the sharp factor 1/T_q\bigl(1 + 2(\lambda_0 - c)/(c - a)\bigr)^2 in place of 4(\cdot)^{2q}; they differ by (1 + \rho^{2q})^2 \le 4 (rule B6). [Saad2011, Theorem 6.4] (the case i = 1; locator to verify); there with a = \lambda_{n}, c = \lambda_1, an eigenvector of a simple eigenvalue and the Chebyshev form.
Lean statement and details
Matrix.IsHermitian.eigenvalue_sub_eigenvalue_conjTranspose_mul_mul_le.{u_1, u_2, u_3} {𝕜 : Type u_1}
[RCLike 𝕜] {n : Type u_2} {r : Type u_3} [Fintype n] [DecidableEq n] [Fintype r] [DecidableEq r]
{A : Matrix n n 𝕜} (hA : A.IsHermitian) {a c : ℝ} (hac : a < c) (hc : c < eigenvalue A 0)
(hs : spectrum ℝ A ⊆ Set.Icc a c ∪ {eigenvalue A 0}) {b : n → 𝕜}
(hb : 0 < (spectralMeasure A b).real {eigenvalue A 0}) {Q : Matrix n r 𝕜}
(hQ : HasOrthonormalCols Q) {q : ℕ} (hK : Q.mulVecLin.range = krylovSpace A b (q + 1)) :
eigenvalue A 0 - eigenvalue (Qᴴ * A * Q) 0 ≤
4 * (eigenvalue A 0 - a) * spectralTangentSq A b (eigenvalue A 0) *
((√(eigenvalue A 0 - a) - √(eigenvalue A 0 - c)) /
(√(eigenvalue A 0 - a) + √(eigenvalue A 0 - c))) ^
(2 * q)Theorem (Lanczos breaks down exactly at the grade).
for Hermitian \mathbf{A} and the recurrence from \mathbf{b}, \beta_{j+1} = 0 iff \nu \le j + 1, \nu the grade of \mathbf{b}. [Saad2003, Proposition 6.6]; stated there for the Arnoldi process, of which Lanczos is the symmetric case ([Saad2003, Theorem 6.19]), at the first zero coefficient; here the coefficient stays zero from the grade on.
Lean statement and details
Matrix.IsHermitian.lanczosState_beta_eq_zero_iff.{u_1, u_2} {𝕜 : Type u_1} [RCLike 𝕜] {n : Type u_2}
[Fintype n] [DecidableEq n] {A : Matrix n n 𝕜} (hA : A.IsHermitian) (b : n → 𝕜) (j : ℕ) :
(lanczosState A b (j + 1)).beta = 0 ↔ krylovGrade A b ≤ j + 1Theorem (The Lanczos tridiagonal is the Jacobi matrix of the spectral measure).
for Hermitian \mathbf{A} and every q, the tridiagonal matrix of q steps of the Lanczos recurrence from \mathbf{b} is \mathbf{J}_q(\mu_{\mathbf{A},\mathbf{b}}); past the grade both are padded with the same zeros. [GolubMeurant2010, Ch. 4]; [Gautschi2004, §3.1] (locators to check).
Lean statement and details
Matrix.IsHermitian.lanczosTridiagonal_eq_jacobiMatrix.{u_1, u_2} {𝕜 : Type u_1} [RCLike 𝕜]
{n : Type u_2} [Fintype n] [DecidableEq n] {A : Matrix n n 𝕜} (hA : A.IsHermitian) (b : n → 𝕜)
(q : ℕ) : lanczosTridiagonal A b q = (jacobiMatrix (spectralMeasure A b) q).map ⇑(algebraMap ℝ 𝕜)Theorem (The Lanczos vectors are the orthogonal polynomials of the spectral measure).
for Hermitian \mathbf{A}, every q and j < q, column j of the canonical Lanczos basis \mathsf{arnoldiMatrix}(\mathbf{A}, \mathbf{b}, q) is \pi_j(\mathbf{A})\mathbf{b}/\|\pi_j(\mathbf{A})\mathbf{b}\|, \pi_j the monic orthogonal polynomial of degree j of \mu_{\mathbf{A},\mathbf{b}}; from the grade on both sides are \mathbf{0}. [GolubMeurant2010, Ch. 4] (locator to check).
Lean statement and details
Matrix.IsHermitian.arnoldiMatrix_col_eq_smul_aeval_orthogonalPolynomial_mulVec.{u_1, u_2}
{𝕜 : Type u_1} [RCLike 𝕜] {n : Type u_2} [Fintype n] [DecidableEq n] {A : Matrix n n 𝕜}
(hA : A.IsHermitian) (b : n → 𝕜) {q : ℕ} (j : Fin q) :
(arnoldiMatrix A b q).col j =
(↑‖WithLp.toLp 2
((Polynomial.aeval A) (orthogonalPolynomial (spectralMeasure A b) ↑j) *ᵥ b)‖)⁻¹ •
(Polynomial.aeval A) (orthogonalPolynomial (spectralMeasure A b) ↑j) *ᵥ bTheorem (The Lanczos recurrence computes the canonical basis).
, for Hermitian \mathbf{A} and every q, with no breakdown hypothesis: the basis computed by q steps from \mathbf{b} is \mathsf{arnoldiMatrix}(\mathbf{A}, \mathbf{b}, q); past the grade both are zero. [Saad2011, §6.6].
Lean statement and details
Matrix.IsHermitian.lanczosMatrix_eq_arnoldiMatrix.{u_1, u_2} {𝕜 : Type u_1} [RCLike 𝕜]
{n : Type u_2} [Fintype n] [DecidableEq n] {A : Matrix n n 𝕜} (hA : A.IsHermitian) (b : n → 𝕜)
(q : ℕ) : lanczosMatrix A b q = arnoldiMatrix A b qTheorem (O(\log(N)/\sqrt{\varepsilon}) multiplications suffice for random-start Lanczos).
there is an absolute constant C > 0 such that for every positive semidefinite real \mathbf{A} of size N = \lvert n\rvert, a standard Gaussian start \mathbf{g} (law \mathcal{N}(\mathbf{0}, \mathbf{I}) on \mathbb{R}^n), \varepsilon > 0 and q \ge C\log(2N)/\sqrt{\varepsilon} multiplications, the largest Ritz value \theta_0 of \mathcal{K}_{q+1}(\mathbf{A}, \mathbf{g}), written as \lambda_0(\mathbf{P}\mathbf{A}\mathbf{P}) with \mathbf{P} the orthogonal projector onto it, satisfies \mathbb{E}\bigl[\lambda_0(\mathbf{A}) - \theta_0\bigr] \le \varepsilon\,\lambda_0(\mathbf{A})\,. The asymptotic form of NLAlib.integral_eigenvalue_sub_eigenvalue_rangeProjector_mul_mul_le_of_hasLaw_gaussianVector. [KuczynskiWozniakowski1992, Theorem 4.2] (locator to check). Asymptotic: NLAlib.integral_eigenvalue_sub_eigenvalue_rangeProjector_mul_mul_le_of_hasLaw_gaussianVector
General form: sizes are index types
Lean statement and details
NLAlib.exists_forall_integral_eigenvalue_sub_eigenvalue_rangeProjector_mul_mul_le_of_hasLaw_gaussianVector :
∃ C,
0 < C ∧
∀ {Ω : Type} [inst : MeasurableSpace Ω] {μ : Measure Ω} {n : Type} [inst_1 : Fintype n]
[inst_2 : DecidableEq n] {g : Ω → n → ℝ},
HasLaw g (gaussianVector n) μ →
∀ {A : Matrix n n ℝ},
A.PosSemidef →
∀ (ε : ℝ) (q : ℕ),
0 < ε →
C * Real.log (2 * ↑(Fintype.card n)) / √ε ≤ ↑q →
∫ (ω : Ω),
eigenvalue A 0 -
eigenvalue
(rangeProjector (krylovMatrix A (g ω) (q + 1)) * A *
rangeProjector (krylovMatrix A (g ω) (q + 1)))
0 ∂μ ≤
ε * eigenvalue A 0Theorem (The gap-free Ritz-value bound).
for positive semidefinite \mathbf{A}, 0 < \varepsilon < 1, a vector \mathbf{b} with a component in the top eigenspace E_{\lambda_0} of \lambda_0 = \lambda_0(\mathbf{A}), and the largest Ritz value \theta_0 of \mathcal{K}_{q+1}(\mathbf{A}, \mathbf{b}) (the largest eigenvalue of \mathbf{Q}^{\mathsf{H}}\mathbf{A}\mathbf{Q} for \mathbf{Q} with orthonormal columns spanning it), \lambda_0 - \theta_0 \le \varepsilon\lambda_0 + 4e^{-4q\sqrt{\varepsilon}}\lambda_0\tan^2\angle(\mathbf{b}, E_{\lambda_0})\,, \tan^2\angle(\mathbf{b}, E_{\lambda_0}) the ratio \mu_{\mathbf{A},\mathbf{b}}(\mathbb{R}\setminus\{\lambda_0\})/ \mu_{\mathbf{A},\mathbf{b}}(\{\lambda_0\}) of the spectral measure. Sharp form: 1/T_q((1 + \varepsilon)/(1 - \varepsilon))^2 in place of 4e^{-4q\sqrt\varepsilon} (exp_mul_sqrt_div_two_le_eval_T_real); the factor lost is e^{4q(\operatorname{artanh}\sqrt\varepsilon - \sqrt\varepsilon)}(1 + \rho^{2q})^2 with \rho = (1 - \sqrt\varepsilon)/(1 + \sqrt\varepsilon), which is unbounded in q at fixed \varepsilon (its exponent is about 4q\varepsilon^{3/2}/3 for small \varepsilon). Incomparable with Matrix.PosSemidef.eigenvalue_sub_eigenvalue_conjTranspose_mul_mul_le_div_sq: this bound is better for a fixed target accuracy with a good start, that one needs no \varepsilon and degrades only logarithmically with a poor start. [MuscoMusco2015, Theorem 1] (single-vector case; locator to check; the library cites this paper as Theorem 10 (proof), Lemmas 2, 5, 9 and Algorithm 2, all for the block method); there with (1 + \sqrt{2\varepsilon/(1-\varepsilon)})^{-2q}, weaker for small \varepsilon and stronger as \varepsilon \to 1; constants composed here.
Lean statement and details
Matrix.PosSemidef.eigenvalue_sub_eigenvalue_conjTranspose_mul_mul_le_add.{u_1, u_2, u_3}
{𝕜 : Type u_1} [RCLike 𝕜] {n : Type u_2} {r : Type u_3} [Fintype n] [DecidableEq n] [Fintype r]
[DecidableEq r] {A : Matrix n n 𝕜} (hA : A.PosSemidef) {ε : ℝ} (hε₀ : 0 < ε) (hε₁ : ε < 1)
{b : n → 𝕜} (hb : 0 < (spectralMeasure A b).real {eigenvalue A 0}) {Q : Matrix n r 𝕜}
(hQ : HasOrthonormalCols Q) {q : ℕ} (hK : Q.mulVecLin.range = krylovSpace A b (q + 1)) :
eigenvalue A 0 - eigenvalue (Qᴴ * A * Q) 0 ≤
ε * eigenvalue A 0 +
4 * rexp (-4 * ↑q * √ε) * eigenvalue A 0 * spectralTangentSq A b (eigenvalue A 0)Mathematical background
Spectral theory
The spectral theorem, eigenvalue variational principles, interlacing, and positive definiteness.
Orthogonal polynomials and quadrature
Three-term recurrences and Gauss, Gauss–Radau, and Gauss–Lobatto quadrature.
Krylov spaces
Krylov spaces, grade, and polynomial projections underlying CG, Lanczos, and Arnoldi.
Finite-precision Krylov analysis
Local recurrence defects, backward models, residual gaps, Paige bounds, and rounded matrix-function estimates.
Appears under these tasks
Eigenvalues
Approximate extremal or interior eigenvalues and their invariant subspaces.
Matrix functions
Approximate f(\mathbf{A})\mathbf{b} or evaluate a matrix function.
Trace estimation and spectral statistics
Estimate \operatorname{tr}(\mathbf{A}), \operatorname{tr}(f(\mathbf{A})), and related quantities.
Quadrature and quadratic forms
Approximate integrals and quantities such as \mathbf{b}^{\mathsf{T}}f(\mathbf{A})\mathbf{b}.
Krylov factorizations
Construct orthonormal Krylov bases and Hessenberg, tridiagonal, or bidiagonal factorizations.