The Lanczos algorithm is an iterative Krylov subspace method that efficiently approximates a few extreme eigenvalues and eigenvectors of a large, sparse, symmetric matrix by reducing it to a smaller, symmetric tridiagonal matrix. It operates by constructing an orthonormal basis for the Krylov subspace generated by the matrix and a starting vector, iteratively building the tridiagonal representation. This process is fundamental to low-rank factorization techniques, as it enables the extraction of dominant spectral components for compression and approximation.
Glossary
Lanczos Algorithm

What is the Lanczos Algorithm?
The Lanczos algorithm is a cornerstone iterative method in numerical linear algebra for approximating eigenvalues and eigenvectors of large, sparse, symmetric matrices.
The algorithm's power lies in its ability to handle matrices far too large for direct decomposition methods like full Singular Value Decomposition (SVD). Its core output, the Lanczos decomposition, provides the tridiagonal matrix whose eigenvalues (Ritz values) approximate those of the original. This makes it critical for Principal Component Analysis (PCA) on massive datasets and is the foundation for the implicitly restarted Lanczos method used in software like ARPACK. Its efficiency depends heavily on the matrix being sparse to enable fast matrix-vector products.
Key Characteristics of the Lanczos Algorithm
The Lanczos algorithm is an iterative Krylov subspace method for approximating a few extreme eigenvalues and eigenvectors of a large, sparse, symmetric matrix by tridiagonalizing it.
Krylov Subspace Foundation
The algorithm iteratively builds an orthonormal basis for the Krylov subspace K_m(A, v) = span{v, Av, A^2v, ..., A^{m-1}v}, where A is the input matrix and v is a random starting vector. This subspace naturally contains information about A's extreme eigenvalues. The process generates a sequence of vectors using only matrix-vector multiplications, making it highly efficient for sparse matrices where such operations are cheap.
Tridiagonal Matrix Reduction
A core output of the Lanczos iteration is a symmetric tridiagonal matrix T_m. This small, dense matrix (m x m, where m << n) is a projection of the large n x n matrix A onto the Krylov subspace. The eigenvalues of T_m (Ritz values) are excellent approximations to the extreme eigenvalues of A. This reduction from a large sparse matrix to a small tridiagonal one is what makes the eigenvalue problem computationally tractable.
- Structure:
T_mhas non-zero entries only on its main diagonal and the first sub- and super-diagonals. - Efficiency: Its eigenvalues can be found using fast, specialized methods like the QR algorithm.
Three-Term Recurrence Relation
The Lanczos process is defined by a three-term recurrence that generates new basis vectors. For a symmetric matrix A, the recurrence is:
β_j q_{j+1} = A q_j - α_j q_j - β_{j-1} q_{j-1}
where q_j are the orthonormal Lanczos vectors, α_j = q_j^T A q_j, and β_j = ||A q_j - α_j q_j - β_{j-1} q_{j-1}||. This elegant recurrence means each new vector q_{j+1} is computed using only the previous two vectors (q_j and q_{j-1}) and a single matrix-vector product with A. It avoids the full Gram-Schmidt orthogonalization against all previous vectors, which would be prohibitively expensive.
Loss of Orthogonality & Practical Stabilization
In finite-precision arithmetic, the Lanczos vectors lose orthogonality due to rounding errors, causing spurious duplicate eigenvalues to appear. This is a fundamental numerical instability. Practical implementations use selective reorthogonalization or the full reorthogonalization scheme to stabilize the process.
- Selective: Only reorthogonalize against converged Ritz vectors.
- Full: Maintain full orthogonality of all Lanczos vectors, at increased cost.
- Implicit Restart: Modern libraries like ARPACK use the Implicitly Restarted Lanczos Method (IRLM), which combines the Lanczos process with polynomial filtering to focus on desired eigenvalues and manage subspace size.
Connection to Other Algorithms
The Lanczos algorithm is the foundational prototype for several key numerical methods:
- Arnoldi Iteration: The generalization of Lanczos for non-symmetric matrices, which produces an upper Hessenberg matrix instead of a tridiagonal one.
- Conjugate Gradient Method: For solving symmetric positive-definite linear systems
Ax = b, the CG method is mathematically equivalent to the Lanczos algorithm applied toA. - Kernel Methods & Nyström Approximation: The Nyström method for low-rank kernel matrix approximation can use a Lanczos-based procedure to efficiently approximate the eigendecomposition.
Primary Use Cases in Machine Learning
In ML, Lanczos is not typically used for direct model compression but is a critical tool in related linear algebra computations:
- Low-Rank Approximation: Approximating the top singular values/vectors of large data matrices via the Lanczos bidiagonalization algorithm, a variant for SVD.
- Kernel PCA: Enabling scalable Kernel PCA by approximating the eigendecomposition of the large kernel matrix.
- Second-Order Optimization: Approximating the curvature information (Hessian-vector products) in optimizers like Hessian-free optimization or K-FAC.
- Spectral Analysis of Graphs: Finding the largest/smallest eigenvalues of graph Laplacian or adjacency matrices for spectral clustering and embedding.
How the Lanczos Algorithm Works
The Lanczos algorithm is an iterative Krylov subspace method for approximating a few extreme eigenvalues and eigenvectors of a large, sparse, symmetric matrix by tridiagonalizing it.
The Lanczos algorithm is an iterative method for approximating the extreme eigenvalues and eigenvectors of a large, sparse, symmetric matrix. It constructs an orthonormal basis for the Krylov subspace generated by the matrix and a starting vector. This process yields a symmetric tridiagonal matrix whose eigenvalues (Ritz values) approximate those of the original, enabling efficient computation without full matrix decomposition.
The algorithm's efficiency stems from requiring only matrix-vector products, making it ideal for massive matrices where storage is prohibitive. However, it suffers from loss of orthogonality in finite-precision arithmetic, necessitating reorthogonalization techniques. It is foundational for low-rank approximations via eigenvalue decomposition and is a core component in methods like Singular Value Decomposition (SVD) for sparse data.
Applications in AI and Machine Learning
The Lanczos algorithm is a cornerstone iterative method for large-scale eigenvalue problems. In AI/ML, it provides the computational engine for key dimensionality reduction and model compression techniques.
Core Mechanism for Large-Scale PCA
Principal Component Analysis (PCA) on massive datasets requires computing the dominant eigenvectors of the covariance matrix. The Lanczos algorithm efficiently approximates these eigenvectors without forming the full covariance matrix, which is often intractably large. This enables PCA on datasets with millions of samples and high-dimensional features, such as in genomics or large-scale image datasets.
- Key Advantage: Operates via matrix-vector products, avoiding O(n³) full eigendecomposition.
- Use Case: Dimensionality reduction for pre-processing before training deep neural networks.
Foundation for Truncated SVD in Model Compression
Truncated Singular Value Decomposition (SVD) is a fundamental low-rank factorization technique for compressing neural network layers. The Lanczos algorithm computes the leading singular values and vectors needed for the approximation. By decomposing a large weight matrix W (m x n) into U_k, Σ_k, V_k^T, the parameter count is reduced from m x n to k x (m + n + 1).
- Application: Compressing fully-connected and convolutional layers (via reshaping filters).
- Impact: Directly reduces model size and inference latency, critical for on-device deployment.
Enabling Kernel Methods & Spectral Clustering
Kernel PCA and spectral clustering rely on the eigendecomposition of the kernel (Gram) matrix or graph Laplacian. For large datasets, these matrices are dense and enormous. The Lanczos algorithm, often coupled with the Nyström method for approximation, enables the extraction of the dominant eigenpairs. This makes non-linear dimensionality reduction and graph-based clustering feasible at scale.
- Example: Community detection in large social networks or manifold learning for visualization.
Accelerating Deep Learning Optimizers
Second-order optimization methods like Natural Gradient Descent and K-FAC (Kronecker-Factored Approximate Curvature) require approximating the inverse of large Fisher Information or Hessian matrices. The Lanczos algorithm is used to perform a low-rank approximation of these matrices, enabling efficient computation of the preconditioner. This can lead to faster convergence during the training of large models.
- Mechanism: Builds a Krylov subspace to approximate the curvature information.
- Benefit: Reduces the number of training iterations, saving computational cost.
Critical for Randomized Linear Algebra
Modern randomized numerical linear algebra (RandNLA) techniques often use the Lanczos algorithm as a subroutine. Methods like Randomized SVD first use random projection to sketch a matrix to a smaller subspace, then apply a deterministic algorithm like Lanczos to compute the final SVD of the sketch. This hybrid approach provides robust performance guarantees and is the state-of-the-art for factorizing massive matrices in ML.
- Synergy: Combines statistical sampling (speed) with iterative refinement (accuracy).
- Result: Enables factorization of matrices that do not fit in memory.
Underpinning Model-Based Reinforcement Learning
In model-based reinforcement learning (MBRL), agents learn a dynamics model of their environment. Linear-quadratic regulator (LQR) controllers, often used for planning within these models, require solving algebraic Riccati equations. The Lanczos algorithm can be employed to solve the associated large-scale eigenvalue problems efficiently, enabling real-time control in high-dimensional state spaces.
- Connection: Related to solving Lyapunov and Sylvester equations for system stability analysis.
- Domain: Robotics and autonomous systems where the state dimension is large.
Lanczos Algorithm vs. Other Eigenvalue Methods
A feature comparison of the Lanczos algorithm against other principal methods for computing eigenvalues and eigenvectors, focusing on suitability for large-scale, sparse problems in model compression and low-rank factorization.
| Feature / Metric | Lanczos Algorithm | Full Dense Eigensolvers (e.g., QR Algorithm) | Power Iteration | Randomized SVD |
|---|---|---|---|---|
Primary Use Case | Extreme eigenvalues of large, sparse, symmetric matrices | All eigenvalues of dense, small-to-medium matrices | Dominant eigenvalue (largest magnitude) of any matrix | Low-rank approximation via top singular values of large matrices |
Matrix Type Compatibility | Sparse, Symmetric/Hermitian | Dense, General | Any (square) | Any (rectangular) |
Computational Complexity (for k eigenvalues) | O(nnz * k) + O(n * k²) (Iterative, matrix-vector multiplies) | O(n³) (Direct, full decomposition) | O(nnz * k) (Iterative, per iteration) | O(nnz * k) + O(n * k²) (Randomized projection) |
Memory Footprint | Low (stores Krylov subspace basis) | High (requires full dense matrix storage) | Very Low (stores few vectors) | Moderate (stores random projectors and basis) |
Output Precision | Approximation (converges to true extremal eigenvalues) | Exact (up to machine precision for full decomposition) | Approximation (only dominant eigenvalue/vector) | Approximation (probabilistic error bounds) |
Ability to Find Interior Eigenvalues | ||||
Exploits Matrix Sparsity | ||||
Foundation for Low-Rank Approx. (via SVD) | Yes (via tridiagonal eigenproblem for AᵀA or AAᵀ) | Yes (but inefficient for large matrices) | Indirectly (for dominant singular vector) | Yes (primary designed method) |
Parallelization Potential | Moderate (matrix-vector multiply is main bottleneck) | High (dense linear algebra libraries) | High (embarrassingly parallel per iteration) | High (randomized steps are parallelizable) |
Common Application in AI/ML | Extreme eigen computation for large-scale PCA, spectral methods | Theoretical analysis, small covariance matrices | PageRank, simple dominance analysis | Dimensionality reduction, approximate matrix factorization |
Frequently Asked Questions
The Lanczos algorithm is a cornerstone iterative method in numerical linear algebra for approximating eigenvalues and eigenvectors of large, sparse matrices. These questions address its core mechanics, applications in machine learning, and practical considerations for implementation.
The Lanczos algorithm is an iterative Krylov subspace method for approximating a few extreme eigenvalues and eigenvectors of a large, sparse, symmetric matrix by tridiagonalizing it. It works by starting with a random initial vector and iteratively constructing an orthonormal basis for the Krylov subspace, defined as the span of vectors generated by repeated multiplication with the matrix. This process yields a symmetric tridiagonal matrix of much smaller dimension whose eigenvalues (Ritz values) approximate the extreme eigenvalues of the original large matrix. The algorithm's power lies in its ability to focus computational effort on the subspace most relevant to the extreme eigenvalues, avoiding the prohibitive cost of full matrix diagonalization.
Key steps in the iteration:
- Initialization: Choose a random starting vector (b), normalize it to get (q_1).
- Lanczos Iteration: For (j = 1, 2, ... m):
- Compute (v = A q_j) (the primary matrix-vector product).
- Orthogonalize (v) against the previous two Lanczos vectors (q_{j-1}) and (q_j) to enforce the three-term recurrence, producing coefficients (\alpha_j) and (\beta_j).
- Normalize the result to obtain the next Lanczos vector (q_{j+1}).
- Result: After (m) steps, we have (Q_m = [q_1, q_2, ..., q_m]) and a tridiagonal matrix (T_m) such that (A Q_m \approx Q_m T_m). The eigenvalues of (T_m) approximate those of (A).
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
The Lanczos algorithm is a foundational iterative method within the broader field of low-rank matrix approximation and eigenvalue computation. These related concepts provide the mathematical and algorithmic context for its application.
Krylov Subspace Methods
The Lanczos algorithm is a specific instance of a Krylov subspace method. These are iterative algorithms for solving large-scale eigenvalue problems and linear systems of the form (Ax = b). They construct an approximation subspace, the Krylov subspace, generated by repeated matrix-vector products: (\mathcal{K}_k(A, v) = \text{span}{v, Av, A^2v, ..., A^{k-1}v}).
- Core Principle: For large, sparse matrices, these methods avoid forming the full matrix, relying only on matrix-vector multiplications.
- Key Variants: The Arnoldi iteration generalizes Lanczos to non-symmetric matrices. The Conjugate Gradient method is a Krylov subspace solver for symmetric positive-definite linear systems.
Singular Value Decomposition (SVD)
Singular Value Decomposition (SVD) is the definitive matrix factorization, expressing any matrix (A) as (A = U\Sigma V^T), where (U) and (V) are orthogonal matrices and (\Sigma) is a diagonal matrix of singular values. The Lanczos algorithm can be used to efficiently compute a partial SVD for large, sparse matrices.
- Connection to Lanczos: Applying Lanczos to the matrices (A^TA) and (AA^T) yields approximations of the singular vectors and values.
- Low-Rank Approximation: The Truncated SVD, keeping only the top-(k) singular values/vectors, is the optimal rank-(k) approximation (Eckart–Young theorem), a primary goal in model compression.
Rayleigh Quotient
The Rayleigh quotient is a scalar function (R(A, x) = \frac{x^T A x}{x^T x}) for a symmetric matrix (A) and a non-zero vector (x). It provides a crucial estimate for an eigenvalue.
- Min-Max Principle: For a symmetric matrix, the minimum and maximum values of the Rayleigh quotient over all vectors are the smallest and largest eigenvalues, respectively.
- Role in Lanczos: The Ritz values and vectors computed in the Lanczos algorithm are derived from the Rayleigh quotient restricted to the Krylov subspace, providing increasingly accurate approximations to the extreme eigenvalues.
Power Iteration
Power iteration is the simplest iterative method for finding the dominant eigenvector (associated with the eigenvalue of largest magnitude) of a diagonalizable matrix. It repeatedly applies the matrix to a vector: (x_{k+1} = \frac{A x_k}{|A x_k|}).
- Limitation: It finds only one eigenvector. Subspace iteration extends it to find multiple eigenvectors.
- Foundation: The Lanczos algorithm can be viewed as a sophisticated generalization. While power iteration uses information from a single vector sequence, Lanczos orthogonalizes the entire Krylov subspace, enabling the simultaneous approximation of multiple eigenvalues and eigenvectors with far superior convergence.
Tridiagonal Matrix
A tridiagonal matrix has non-zero entries only on the main diagonal and the diagonals immediately above and below it. This structure is central to the Lanczos algorithm's efficiency.
- Lanczos Tridiagonalization: For an (n \times n) symmetric matrix (A), the Lanczos process produces an orthonormal basis (Q_k) and a symmetric tridiagonal matrix (T_k) such that (A Q_k \approx Q_k T_k).
- Computational Benefit: The eigenvalue problem for the large, sparse (A) is reduced to the much simpler problem of finding eigenvalues of the small, dense tridiagonal matrix (T_k), which can be solved efficiently using the QR algorithm.
Randomized SVD
Randomized SVD is a modern, highly scalable algorithm for low-rank matrix approximation. It uses random sampling to construct a small subspace that captures the matrix's range, followed by a deterministic SVD on the reduced matrix.
- Process: It projects the input matrix onto a random low-dimensional subspace, then performs a standard SVD on the projected matrix.
- Comparison to Lanczos: While Lanczos is deterministic and optimal for the Krylov subspace it builds, randomized SVD is often faster for very large matrices and is highly parallelizable. It provides a probabilistic guarantee of accuracy and is less susceptible to the numerical instability (loss of orthogonality) that plagues the naive Lanczos algorithm.

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us