Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Let ARn×n\vec{A}\in\R^{n\times n} be a symmetric matrix with eigendecomposition A=i=1nλiuiuiT\vec{A} = \sum_{i=1}^{n} \lambda_i \vec{u}_i \vec{u}_i^\T, where λi\lambda_i are the eigenvalues and ui\vec{u}_i are the orthonormal eigenvectors of A\vec{A}. Recall the matrix function

f(A):=i=1nf(λi)uiuiT.f(\vec{A}) := \sum_{i=1}^{n} f(\lambda_i) \vec{u}_i \vec{u}_i^\T.

A natural approach is to combine the implicit trace estimation algorithms discussed earlier in this chapter with black-box methods for approximating xxTf(A)x\vec{x}\mapsto \vec{x}^\T f(\vec{A})\vec{x} or xf(A)x\vec{x}\mapsto f(\vec{A})\vec{x}, such as the Lanczos method for matrix functions.

Stochastic Lanczos Quadrature

Recall that using k1k-1 matrix-vector products with A\vec{A}, the Lanczos method for quadratic forms produces an approximation Lan-QFk(f;A,x)\Call{Lan-QF}_k(f;\vec{A},\vec{x}) that is an approximation to xTf(A)x\vec{x}^\T f(\vec{A})\vec{x}. Stochastic Lanczos Quadrature (SLQ) simply combines this method with the Girard-Hutchinson trace estimator.

A simple application of the triangle inequality gives a bound on expected squared error of the SLQ estimator.

Proof

By the triangle inequality and since (x+y)22(x2+y2)(x+y)^2\leq 2(x^2+y^2), we have

tr(f(A))SLQk,m(f;A)22tr(f(A))1mi=1mxiTf(A)xi2+21mi=1m(xiTf(A)xiLan-QFk(f;A,xi))2.\begin{aligned} &| \tr(f(\vec{A})) - \Call{SLQ}_{k,m}(f;\vec{A}) |^2 \\&\hspace{4em}\leq 2\left| \tr(f(\vec{A})) - \frac{1}{m}\sum_{i=1}^{m} \vec{x}_i^\T f(\vec{A})\vec{x}_i \right|^2 \\&\hspace{5em}+ 2\left| \frac{1}{m}\sum_{i=1}^{m} \left( \vec{x}_i^\T f(\vec{A})\vec{x}_i - \Call{Lan-QF}_k(f;\vec{A},\vec{x}_i) \right) \right|^2. \end{aligned}

Note that

E[tr(f(A))1mi=1mxiTf(A)xi2]=V[tr^m(f(A))]=2f(A)F2m,\EE\left[ \left| \tr(f(\vec{A})) - \frac{1}{m}\sum_{i=1}^{m} \vec{x}_i^\T f(\vec{A})\vec{x}_i \right|^2 \right] = \VV\left[ \widehat{\tr}_m(f(\vec{A})) \right] = \frac{2 \| f(\vec{A}) \|_\F^2}{m},

where tr^m()\widehat{\tr}_m(\cdot) is the Girard--Hutchinson estimator.

Next, by the triangle inequality and Theorem 1.3,

1mi=1m(xiTf(A)xiLan-QFk(f;A,xi))1mi=1mxiTf(A)xiLan-QFk(f;A,xi)2mi=1mxi2mindeg(p)<2k1maxx[λn,λ1]f(x)p(x).\begin{aligned} \hspace{4em}&\hspace{-4em} \left| \frac{1}{m}\sum_{i=1}^{m} \left( \vec{x}_i^\T f(\vec{A})\vec{x}_i - \Call{Lan-QF}_k(f;\vec{A},\vec{x}_i) \right) \right| \\&\leq \frac{1}{m}\sum_{i=1}^{m} \left| \vec{x}_i^\T f(\vec{A})\vec{x}_i - \Call{Lan-QF}_k(f;\vec{A},\vec{x}_i) \right| \\&\leq \frac{2}{m} \sum_{i=1}^{m} \|\vec{x}_i\|^2 \min_{\deg(p)<2k-1} \max_{x\in[\lambda_n,\lambda_1]} | f(x) - p(x) |. \end{aligned}

Hence,

E[1mi=1m(xiTf(A)xiLan-QFk(f;A,xi))2]4m2E[(i=1mxi2)2]mindeg(p)<2k1maxx[λn,λ1]f(x)p(x)2\begin{aligned} \hspace{4em}&\hspace{-4em} \EE\left[ \left| \frac{1}{m}\sum_{i=1}^{m} \left( \vec{x}_i^\T f(\vec{A})\vec{x}_i - \Call{Lan-QF}_k(f;\vec{A},\vec{x}_i) \right) \right|^2 \right] \\&\leq \frac{4}{m^2}\EE\left[ \left(\sum_{i=1}^{m} \|\vec{x}_i\|^2 \right)^2 \right] \min_{\deg(p)<2k-1} \max_{x\in[\lambda_n,\lambda_1]} | f(x) - p(x) |^2 \end{aligned}

Now, note that i=1mxi2\sum_{i=1}^{m} \|\vec{x}_i\|^2 is a Chi-squared random variable with mnmn degrees of freedom. By looking on Wikipedia, we see that

E[(i=1mxi2)2]=2mn+(mn)23(mn)2.\EE\left[ \left(\sum_{i=1}^{m} \|\vec{x}_i\|^2 \right)^2 \right] = 2mn + (mn)^2 \leq 3(mn)^2.

Combining all of the above gives the result.

Note that for “nice” functions f(x)f(x), the error of the best polynomial approximation decreases exponentially with kk Trefethen, 2019.

Variance reduction

As with implicit trace estimation, the accuracy of SLQ can be improved using a control variate. In particular, suppose F^\widehat{\vec{F}} is a low-rank approximation to f(A)f(\vec{A}) whose trace we can compute exactly. Since

tr(f(A))=tr(F^)+tr(f(A)F^),\tr(f(\vec{A})) = \tr(\widehat{\vec{F}}) + \tr(f(\vec{A}) - \widehat{\vec{F}}),

we can estimate the second term with SLQ; i.e. we use the estimator

tr(F^)+1mi=1m(Lan-QFk(f;A,xi)xiTF^xi).\tr(\widehat{\vec{F}}) + \frac{1}{m}\sum_{i=1}^{m} \left( \Call{Lan-QF}_k(f;\vec{A},\vec{x}_i) - \vec{x}_i^\T\widehat{\vec{F}}\vec{x}_i \right).

The variance of this estimator scales with f(A)F^F2\|f(\vec{A}) - \widehat{\vec{F}}\|_\F^2 rather than f(A)F2\|f(\vec{A})\|_\F^2, so it can be substantially more accurate when F^\widehat{\vec{F}} is a good approximation to f(A)f(\vec{A}).

Techniques for efficiently obtaining a low-rank approximation to f(A)f(\vec{A}) are described in Matrix function low-rank approximation. In particular, Krylov-aware methods Chen & Hallman, 2023Persson et al., 2025 were developed with this application in mind, and for operator monotone functions, a suitable F^\widehat{\vec{F}} can be obtained using products with A\vec{A} only.

References
  1. Chen, T. (2024). The Lanczos algorithm for matrix functions: a handbook for scientists. https://arxiv.org/abs/2410.11090
  2. Chen, T., Trogdon, T., & Ubaru, S. (2025). Randomized Matrix-Free Quadrature: Unified and Uniform Bounds for Stochastic Lanczos Quadrature and the Kernel Polynomial Method. SIAM Journal on Scientific Computing, 47(3), A1733–A1757. 10.1137/23m1600414
  3. Trefethen, L. N. (2019). Approximation Theory and Approximation Practice, Extended Edition. Society for Industrial. 10.1137/1.9781611975949
  4. Chen, T., & Hallman, E. (2023). Krylov-Aware Stochastic Trace Estimation. SIAM Journal on Matrix Analysis and Applications, 44(3), 1218–1244. 10.1137/22m1494257
  5. Persson, D., Chen, T., & Musco, C. (2025). Randomized block-Krylov subspace methods for low-rank approximation of matrix functions. https://arxiv.org/abs/2502.01888