In the world of large-scale machine learning and scientific computing, we often need to compute the "action" of a matrix function on a vector, written as $f(\mathbf{A})\mathbf{b}$. Whether you are sampling from a high-dimensional Gaussian distribution, training a Gaussian process, or analyzing the spectral density of a neural network's Hessian, this operation is a fundamental building block.
While many specialized algorithms have been developed for specific functions (like the matrix square root or exponential), a classic technique from the 1950s called the Lanczos method for matrix functions (Lanczos-FA) remains the gold standard in practice. Despite its simplicity, it frequently outperforms its more modern, complex rivals. In their NeurIPS 2024 paper, Amsel et al. finally provide a theoretical "why" for this empirical success.
TL;DR
The authors prove that Lanczos-FA is nearly instance optimal for a broad class of rational functions. This means that for a specific matrix $\mathbf{A}$ and vector $\mathbf{b}$, the algorithm's error is within a constant factor of the best possible approximation achievable by any method using the same amount of information, finally bridging the gap between theory and practice.
What Problem Does This Paper Address?
Computing $f(\mathbf{A})\mathbf{b}$ directly via eigendecomposition is impossible for the massive matrices used in modern ML. Instead, we use Krylov subspace methods, which approximate the result using only matrix-vector products ($\mathbf{b}, \mathbf{A}\mathbf{b}, \mathbf{A}^2\mathbf{b}, \dots$).
The challenge is that existing theory (often called "Fact 3" in the paper) only compares Lanczos-FA to the best uniform polynomial approximation of $f(x)$. This theory ignores the specific "personality" of the matrix $\mathbf{A}$—such as whether its eigenvalues are clustered or have outliers. In practice, Lanczos-FA adapts to these spectral features and converges much faster than the uniform theory predicts. The authors sought to prove that Lanczos-FA is "instance optimal," meaning it performs nearly as well as the absolute best possible polynomial approximation for that specific $(\mathbf{A}, \mathbf{b})$ pair.
Methods
The authors focus on rational functions (ratios of polynomials). This is a powerful choice because many common functions like $\sqrt{x}$, $\log(x)$, and $\exp(x)$ are very well-approximated by low-degree rational functions.
Their key technical contribution is a novel telescoping error decomposition. They show that the error of Lanczos-FA for a complex rational function can be broken down into the errors of simpler linear systems (like $\mathbf{A}^{-1}\mathbf{b}$). Since Lanczos-FA is mathematically equivalent to the Conjugate Gradient (CG) method for linear systems—and CG is known to be optimal in a specific norm—they were able to "transfer" that optimality to the broader class of rational functions.
Datasets and Setup
As a theoretical paper, the "datasets" consist of synthetic matrices designed to test different spectral scenarios:
- Uniformly-spaced spectra: Eigenvalues spread evenly.
- Geometrically-spaced spectra: Eigenvalues clustered near zero.
- Narrow interval with outliers: A common scenario in ML where most eigenvalues are clustered, but a few "spikes" exist.
The authors implemented Lanczos-FA in high-precision arithmetic to observe convergence behavior far beyond standard machine precision.
Key Insights and Ideas
- Adaptivity is Built-in: Lanczos-FA doesn't need to know the spectrum of $\mathbf{A}$ beforehand. It naturally "discovers" clusters and outliers, allowing it to converge at an accelerated rate compared to methods that assume a worst-case spectrum.
- Rational Approximation as a Bridge: Even for non-rational functions like the matrix square root, the paper shows that Lanczos-FA inherits the optimality of the best rational approximation.
- The "Gap" is Justified: As shown in Figure 1, the traditional uniform bound (Fact 3) is often orders of magnitude too pessimistic, while the "Instance Optimal" curve tracks the actual Lanczos-FA error almost perfectly.
Key Results
- Theorem 4 (Main Result): For a rational function of degree $(p, q)$, Lanczos-FA matches the error of the best possible Krylov method up to a multiplicative factor $C$. Crucially, this factor $C$ depends on the matrix's condition number and the function's degree, but not on the number of iterations $k$.
- Qualitative Match: Figure 2 demonstrates that the new theoretical bound (Theorem 4) correctly captures the shape of the convergence curve, unlike previous theories.
- Superiority over Specialized Methods: In head-to-head tests for the matrix sign function, Lanczos-FA significantly outperformed newer, specialized stochastic iterative methods.
Limitations and Future Work
- Pessimistic Prefactors: While the theory proves a constant factor $C$ exists, the current calculated value for $C$ is quite large (exponential in the denominator degree). Experimental evidence suggests the true dependence is much milder, likely closer to $\sqrt{\text{degree}}$.
- Complex Poles: The current proof assumes the rational function has real poles outside the matrix's eigenvalue range. Extending this to complex poles would cover even more functions.
- Finite Precision: The analysis assumes exact arithmetic. While Lanczos is notoriously sensitive to rounding errors, practical implementations are robust, and extending the "instance optimality" proof to finite precision is an open challenge.
For researchers and engineers, this paper provides the peace of mind that when you reach for the classic Lanczos method, you aren't just using an old tool—you're using one that is theoretically nearly as good as it gets.
Summary updated