Lanczos algorithm

The Lanczos algorithm is a direct algorithm devised by Cornelius Lanczos that is an adaptation of power methods to find the ${\displaystyle m}$ "most useful" (tending towards extreme highest/lowest) eigenvalues and eigenvectors of an ${\displaystyle n\times n}$ Hermitian matrix, where ${\displaystyle m}$ is often but not necessarily much smaller than ${\displaystyle n}$.[1] Although computationally efficient in principle, the method as initially formulated was not useful, due to its numerical instability.

In 1970, Ojalvo and Newman showed how to make the method numerically stable and applied it to the solution of very large engineering structures subjected to dynamic loading.[2] This was achieved using a method for purifying the Lanczos vectors (i.e. by repeatedly reorthogonalizing each newly generated vector with all previously generated ones)[2] to any degree of accuracy, which when not performed, produced a series of vectors that were highly contaminated by those associated with the lowest natural frequencies.

In their original work, these authors also suggested how to select a starting vector (i.e. use a random-number generator to select each element of the starting vector) and suggested an empirically determined method for determining ${\displaystyle m}$, the reduced number of vectors (i.e. it should be selected to be approximately 1.5 times the number of accurate eigenvalues desired). Soon thereafter their work was followed by Paige, who also provided an error analysis.[3][4] In 1988, Ojalvo produced a more detailed history of this algorithm and an efficient eigenvalue error test.[5]

The algorithm

Input a Hermitian matrix ${\displaystyle A}$ of size ${\displaystyle n\times n}$, and optionally a number of iterations ${\displaystyle m}$ (as default, let ${\displaystyle m=n}$).
• Strictly speaking, the algorithm does not need access to the explicit matrix, but only a function ${\displaystyle v\mapsto Av}$ that computes the product of the matrix by an arbitrary vector. This function is called at most ${\displaystyle m}$ times.
Output an ${\displaystyle n\times m}$ matrix ${\displaystyle V}$ with orthonormal columns and a tridiagonal real symmetric matrix ${\displaystyle T=V^{*}AV}$ of size ${\displaystyle m\times m}$. If ${\displaystyle m=n}$, then ${\displaystyle V}$ is unitary, and ${\displaystyle A=VTV^{*}}$.
Warning The Lanczos iteration is prone to numerical instability. When executed in non-exact arithmetic, additional measures (as outlined in later sections) should be taken to ensure validity of the results.
1. Let ${\displaystyle v_{1}\in \mathbb {C} ^{n}}$ be an arbitrary vector with Euclidean norm ${\displaystyle 1}$.
2. Abbreviated initial iteration step:
1. Let ${\displaystyle w_{1}'=Av_{1}}$.
2. Let ${\displaystyle \alpha _{1}=w_{1}'^{*}v_{1}}$.
3. Let ${\displaystyle w_{1}=w_{1}'-\alpha _{1}v_{1}}$.
3. For ${\displaystyle j=2,\dots ,m}$ do:
1. Let ${\displaystyle \beta _{j}=\|w_{j-1}\|}$ (also Euclidean norm).
2. If ${\displaystyle \beta _{j}\neq 0}$, then let ${\displaystyle v_{j}=w_{j-1}/\beta _{j}}$,
else pick as ${\displaystyle v_{j}}$ an arbitrary vector with Euclidean norm ${\displaystyle 1}$ that is orthogonal to all of ${\displaystyle v_{1},\dots ,v_{j-1}}$.
3. Let ${\displaystyle w_{j}'=Av_{j}}$.
4. Let ${\displaystyle \alpha _{j}=w_{j}'^{*}v_{j}}$.
5. Let ${\displaystyle w_{j}=w_{j}'-\alpha _{j}v_{j}-\beta _{j}v_{j-1}}$.
4. Let ${\displaystyle V}$ be the matrix with columns ${\displaystyle v_{1},\dots ,v_{m}}$. Let ${\displaystyle T={\begin{pmatrix}\alpha _{1}&\beta _{2}&&&&0\\\beta _{2}&\alpha _{2}&\beta _{3}&&&\\&\beta _{3}&\alpha _{3}&\ddots &&\\&&\ddots &\ddots &\beta _{m-1}&\\&&&\beta _{m-1}&\alpha _{m-1}&\beta _{m}\\0&&&&\beta _{m}&\alpha _{m}\\\end{pmatrix}}}$.
Note ${\displaystyle Av_{j}=w_{j}'=\beta _{j+1}v_{j+1}+\alpha _{j}v_{j}+\beta _{j}v_{j-1}}$ for ${\displaystyle 1.

There are in principle four ways to write the iteration procedure. Paige and other works show that the above order of operations is the most numerically stable.[6][7] In practice the initial vector ${\displaystyle v_{1}}$ may be taken as another argument of the procedure, with ${\displaystyle \beta _{j}=0}$ and indicators of numerical imprecision being included as additional loop termination conditions.

Not counting the matrix–vector multiplication, each iteration does ${\displaystyle O(n)}$ arithmetical operations. If ${\displaystyle d}$ is the average number of nonzero elements in a row of ${\displaystyle A}$, then the matrix–vector multiplication can be done in ${\displaystyle O(dn)}$ arithmetical operations. Total complexity is thus ${\displaystyle O(dmn)}$, or ${\displaystyle O(dn^{2})}$ if ${\displaystyle m=n}$; the Lanczos algorithm can be really fast for sparse matrices. Schemes for improving numerical stability are typically judged against this high performance.

The vectors ${\displaystyle v_{j}}$ are called Lanczos vectors. The vector ${\displaystyle w_{j}'}$ is not used after ${\displaystyle w_{j}}$ is computed, and the vector ${\displaystyle w_{j}}$ is not used after ${\displaystyle v_{j+1}}$ is computed. Hence one may use the same storage for all three. Likewise, if only the tridiagonal matrix ${\displaystyle T}$ is sought, then the raw iteration does not need ${\displaystyle v_{j-1}}$ after having computed ${\displaystyle w_{j}}$, although some schemes for improving the numerical stability would need it later on. Sometimes the subsequent Lanczos vectors are recomputed from ${\displaystyle v_{1}}$ when needed.

Application to the eigenproblem

The Lanczos algorithm is most often brought up in the context of finding the eigenvalues and eigenvectors of a matrix, but whereas an ordinary diagonalization of a matrix would make eigenvectors and eigenvalues apparent from inspection, the same is not true for the tridiagonalization performed by the Lanczos algorithm; nontrivial additional steps are needed to compute even a single eigenvalue or eigenvector. Nonetheless, applying the Lanczos algorithm is often a significant step forward in computing the eigendecomposition. If ${\displaystyle \lambda }$ is an eigenvalue of ${\displaystyle A}$, and if ${\displaystyle Tx=\lambda x}$ (${\displaystyle x}$ is an eigenvector of ${\displaystyle T}$) then ${\displaystyle y=Vx}$ is the corresponding eigenvector of ${\displaystyle A}$ (since ${\displaystyle Ay=AVx=VTV^{*}Vx=VTIx=VTx=V(\lambda x)=\lambda Vx=\lambda y}$). Thus the Lanczos algorithm transforms the eigendecomposition problem for ${\displaystyle A}$ into the eigendecomposition problem for ${\displaystyle T}$.

1. For tridiagonal matrices, there exist a number of specialised algorithms, often with better computational complexity than general-purpose algorithms. For example, if ${\displaystyle T}$ is an ${\displaystyle m\times m}$ tridiagonal symmetric matrix then:
• The continuant recursion allows computing the characteristic polynomial in ${\displaystyle O(m^{2})}$ operations, and evaluating it at a point in ${\displaystyle O(m)}$ operations.
• The divide-and-conquer eigenvalue algorithm can be used to compute the entire eigendecomposition of ${\displaystyle T}$ in ${\displaystyle O(m^{2})}$ operations.
• The Fast Multipole Method[8] can compute all eigenvalues in just ${\displaystyle O(m\log m)}$ operations.
2. Some general eigendecomposition algorithms, notably the QR algorithm, are known to converge faster for tridiagonal matrices than for general matrices. Asymptotic complexity of tridiagonal QR is ${\displaystyle O(m^{2})}$ just as for the divide-and-conquer algorithm (though the constant factor may be different); since the eigenvectors together have ${\displaystyle m^{2}}$ elements, this is asymptotically optimal.
3. Even algorithms whose convergence rates are unaffected by unitary transformations, such as the power method and inverse iteration, may enjoy low-level performance benefits from being applied to the tridiagonal matrix ${\displaystyle T}$ rather than the original matrix ${\displaystyle A}$. Since ${\displaystyle T}$ is very sparse with all nonzero elements in highly predictable positions, it permits compact storage with excellent performance vis-à-vis caching. Likewise, ${\displaystyle T}$ is a real matrix with all eigenvectors and eigenvalues real, whereas ${\displaystyle A}$ in general may have complex elements and eigenvectors, so real arithmetic is sufficient for finding the eigenvectors and eigenvalues of ${\displaystyle T}$.
4. If ${\displaystyle n}$ is very large, then reducing ${\displaystyle m}$ so that ${\displaystyle T}$ is of a manageable size will still allow finding the more extreme eigenvalues and eigenvectors of ${\displaystyle A}$; in the ${\displaystyle m\ll n}$ region, the Lanczos algorithm can be viewed as a lossy compression scheme for Hermitian matrices, that emphasises preserving the extreme eigenvalues.

The combination of good performance for sparse matrices and the ability to compute several (without computing all) eigenvalues are the main reasons for choosing to use the Lanczos algorithm.

Application to tridiagonalization

Though the eigenproblem is often the motivation for applying the Lanczos algorithm, the operation the algorithm primarily performs is tridiagonalization of a matrix, for which numerically stable Householder transformations have been favoured since the 1950s. During the 1960s the Lanczos algorithm was disregarded. Interest in it was rejuvenated by the Kaniel–Paige convergence theory and the development of methods to prevent numerical instability, but the Lanczos algorithm remains the alternative algorithm that one tries only if Householder is not satisfactory.[9]

Aspects in which the two algorithms differ include:

• Lanczos takes advantage of ${\displaystyle A}$ being a sparse matrix, whereas Householder does not, and will generate fill-in.
• Lanczos works throughout with the original matrix ${\displaystyle A}$ (and has no problem with it being known only implicitly), whereas raw Householder wants to modify the matrix during the computation (although that can be avoided).
• Each iteration of the Lanczos algorithm produces another column of the final transformation matrix ${\displaystyle V}$, whereas an iteration of Householder produces another factor in a unitary factorisation ${\displaystyle Q_{1}Q_{2}\dots Q_{n}}$ of ${\displaystyle V}$. Each factor is however determined by a single vector, so the storage requirements are the same for both algorithms, and ${\displaystyle V=Q_{1}Q_{2}\dots Q_{n}}$ can be computed in ${\displaystyle O(n^{3})}$ time.
• Householder is numerically stable, whereas raw Lanczos is not.
• Lanczos is highly parallel, with only ${\displaystyle O(n)}$ points of synchronisation (the computations of ${\displaystyle \alpha _{j}}$ and ${\displaystyle \beta _{j}}$). Householder is less parallel, having a sequence of ${\displaystyle O(n^{2})}$ scalar quantities computed that each depend on the previous quantity in the sequence.

Derivation of the algorithm

There are several lines of reasoning which lead to the Lanczos algorithm.

A more provident power method

The power method for finding the largest eigenvalue and a corresponding eigenvector of a matrix ${\displaystyle A}$ is roughly

1. Pick a random vector ${\displaystyle u_{1}\neq 0}$.
2. For ${\displaystyle j\geqslant 1}$ (until the direction of ${\displaystyle u_{j}}$ has converged) do:
1. Let ${\displaystyle u_{j+1}'=Au_{j}.}$
2. Let ${\displaystyle u_{j+1}=u_{j+1}'/\|u_{j+1}'\|.}$
• In the large ${\displaystyle j}$ limit, ${\displaystyle u_{j}}$ approaches the normed eigenvector corresponding to the largest magnitude eigenvalue.

A critique that can be raised against this method is that it is wasteful: it spends a lot of work (the matrix–vector products in step 2.1) extracting information from the matrix ${\displaystyle A}$, but pays attention only to the very last result; implementations typically use the same variable for all the vectors ${\displaystyle u_{j}}$, having each new iteration overwrite the results from the previous one. What if we instead kept all the intermediate results and organised their data?

One piece of information that trivially is available from the vectors ${\displaystyle u_{j}}$ is a chain of Krylov subspaces. One way of stating that without introducing sets into the algorithm is to claim that it computes

a subset ${\displaystyle \{v_{j}\}_{j=1}^{m}}$ of a basis of ${\displaystyle \mathbb {C} ^{n}}$ such that ${\displaystyle Ax\in \operatorname {span} (v_{1},\dotsc ,v_{j+1})}$ for every ${\displaystyle x\in \operatorname {span} (v_{1},\dotsc ,v_{j})}$ and all ${\displaystyle 1\leqslant j

this is trivially satisfied by ${\displaystyle v_{j}=u_{j}}$ as long as ${\displaystyle u_{j}}$ is linearly independent of ${\displaystyle u_{1},\dotsc ,u_{j-1}}$ (and in the case that there is such a dependence then one may continue the sequence by picking as ${\displaystyle v_{j}}$ an arbitrary vector linearly independent of ${\displaystyle u_{1},\dotsc ,u_{j-1}}$). A basis containing the ${\displaystyle u_{j}}$ vectors is however likely to be numerically ill-conditioned, since this sequence of vectors is by design meant to converge to an eigenvector of ${\displaystyle A}$. To avoid that, one can combine the power iteration with a Gram–Schmidt process, to instead produce an orthonormal basis of these Krylov subspaces.

1. Pick a random vector ${\displaystyle u_{1}}$ of Euclidean norm ${\displaystyle 1}$. Let ${\displaystyle v_{1}=u_{1}}$.
2. For ${\displaystyle j=1,\dotsc ,m-1}$ do:
1. Let ${\displaystyle u_{j+1}'=Au_{j}}$.
2. For all ${\displaystyle k=1,\dotsc ,j}$ let ${\displaystyle g_{k,j}=v_{k}^{*}u_{j+1}'}$. (These are the coordinates of ${\displaystyle Au_{j}=u_{j+1}'}$ with respect to the basis vectors ${\displaystyle v_{1},\dotsc ,v_{j}}$.)
3. Let ${\displaystyle w_{j+1}=u_{j+1}'-\sum _{k=1}^{j}g_{k,j}v_{k}}$. (Cancel the component of ${\displaystyle u_{j+1}'}$ that is in ${\displaystyle \operatorname {span} (v_{1},\dotsc ,v_{j})}$.)
4. If ${\displaystyle w_{j+1}\neq 0}$ then let ${\displaystyle u_{j+1}=u_{j+1}'/\|u_{j+1}'\|}$ and ${\displaystyle v_{j+1}=w_{j+1}/\|w_{j+1}\|}$,
otherwise pick as ${\displaystyle u_{j+1}=v_{j+1}}$ an arbitrary vector of Euclidean norm ${\displaystyle 1}$ that is orthogonal to all of ${\displaystyle v_{1},\dotsc ,v_{j}}$.

The relation between the power iteration vectors ${\displaystyle u_{j}}$ and the orthogonal vectors ${\displaystyle v_{j}}$ is that

${\displaystyle Au_{j}=\|u_{j+1}'\|u_{j+1}=u_{j+1}'=w_{j+1}+\sum _{k=1}^{j}g_{k,j}v_{k}=\|w_{j+1}\|v_{j+1}+\sum _{k=1}^{j}g_{k,j}v_{k}}$.

Here it may be observed that we do not actually need the ${\displaystyle u_{j}}$ vectors to compute these ${\displaystyle v_{j}}$, because ${\displaystyle u_{j}-v_{j}\in \operatorname {span} (v_{1},\dotsc ,v_{j-1})}$ and therefore the difference between ${\displaystyle u_{j+1}'=Au_{j}}$ and ${\displaystyle w_{j+1}'=Av_{j}}$ is in ${\displaystyle \operatorname {span} (v_{1},\dotsc ,v_{j})}$, which is cancelled out by the orthogonalisation process. Thus the same basis for the chain of Krylov subspaces is computed by

1. Pick a random vector ${\displaystyle v_{1}}$ of Euclidean norm ${\displaystyle 1}$.
2. For ${\displaystyle j=1,\dotsc ,m-1}$ do:
1. Let ${\displaystyle w_{j+1}'=Av_{j}}$.
2. For all ${\displaystyle k=1,\dotsc ,j}$ let ${\displaystyle h_{k,j}=v_{k}^{*}w_{j+1}'}$.
3. Let ${\displaystyle w_{j+1}=w_{j+1}'-\sum _{k=1}^{j}h_{k,j}v_{k}}$.
4. Let ${\displaystyle h_{j+1,j}=\|w_{j+1}\|}$.
5. If ${\displaystyle h_{j+1,j}\neq 0}$ then let ${\displaystyle v_{j+1}=w_{j+1}/h_{j+1,j}}$,
otherwise pick as ${\displaystyle v_{j+1}}$ an arbitrary vector of Euclidean norm ${\displaystyle 1}$ that is orthogonal to all of ${\displaystyle v_{1},\dotsc ,v_{j}}$.

A priori the coefficients ${\displaystyle h_{k,j}}$ satisfy

${\displaystyle Av_{j}=\sum _{k=1}^{j+1}h_{k,j}v_{k}}$ for all ${\displaystyle j;

the definition ${\displaystyle h_{j+1,j}=\|w_{j+1}\|}$ may seem a bit odd, but fits the general pattern ${\displaystyle h_{k,j}=v_{k}^{*}w_{j+1}'}$ since

${\displaystyle v_{j+1}^{*}w_{j+1}'=v_{j+1}^{*}w_{j+1}=\|w_{j+1}\|v_{j+1}^{*}v_{j+1}=\|w_{j+1}\|.}$

Because the power iteration vectors ${\displaystyle u_{j}}$ that were eliminated from this recursion satisfy ${\displaystyle u_{j}\in \operatorname {span} (v_{1},\ldots ,v_{j}),}$ the vectors ${\displaystyle \{v_{j}\}_{j=1}^{m}}$ and coefficients ${\displaystyle h_{k,j}}$ contain enough information from ${\displaystyle A}$ that all of ${\displaystyle u_{1},\ldots ,u_{m}}$ can be computed, so nothing was lost by switching vectors. (Indeed, it turns out that the data collected here give significantly better approximations of the largest eigenvalue than one gets from an equal number of iterations in the power method, although that is not necessarily obvious at this point.)

This last procedure is the Arnoldi iteration. The Lanczos algorithm then arises as the simplification one gets from eliminating calculation steps that turn out to be trivial when ${\displaystyle A}$ is Hermitian—in particular most of the ${\displaystyle h_{k,j}}$ coefficients turn out to be zero.

Elementarily, if ${\displaystyle A}$ is Hermitian then

${\displaystyle h_{k,j}=v_{k}^{*}w_{j+1}'=v_{k}^{*}Av_{j}=v_{k}^{*}A^{*}v_{j}=(Av_{k})^{*}v_{j}.}$

For ${\displaystyle k we know that ${\displaystyle Av_{k}\in \operatorname {span} (v_{1},\ldots ,v_{j-1})}$, and since ${\displaystyle v_{j}}$ by construction is orthogonal to this subspace, this inner product must be zero. (This is essentially also the reason why sequences of orthogonal polynomials can always be given a three-term recurrence relation.) For ${\displaystyle k=j-1}$ one gets

${\displaystyle h_{j-1,j}=(Av_{j-1})^{*}v_{j}={\overline {v_{j}^{*}Av_{j-1}}}={\overline {h_{j,j-1}}}=h_{j,j-1}}$

since the latter is real on account of being the norm of a vector. For ${\displaystyle k=j}$ one gets

${\displaystyle h_{j,j}=(Av_{j})^{*}v_{j}={\overline {v_{j}^{*}Av_{j}}}={\overline {h_{j,j}}},}$

meaning this is real too.

More abstractly, if ${\displaystyle V}$ is the matrix with columns ${\displaystyle v_{1},\ldots ,v_{m}}$ then the numbers ${\displaystyle h_{k,j}}$ can be identified as elements of the matrix ${\displaystyle H=V^{*}AV}$, and ${\displaystyle h_{k,j}=0}$ for ${\displaystyle k>j+1;}$ the matrix ${\displaystyle H}$ is upper Hessenberg. Since

${\displaystyle H^{*}=\left(V^{*}AV\right)^{*}=V^{*}A^{*}V=V^{*}AV=H}$

the matrix ${\displaystyle H}$ is Hermitian. This implies that ${\displaystyle H}$ is also lower Hessenberg, so it must in fact be tridiagional. Being Hermitian, its main diagonal is real, and since its first subdiagonal is real by construction, the same is true for its first superdiagonal. Therefore, ${\displaystyle H}$ is a real, symmetric matrix—the matrix ${\displaystyle T}$ of the Lanczos algorithm specification.

Simultaneous approximation of extreme eigenvalues

One way of characterising the eigenvectors of a Hermitian matrix ${\displaystyle A}$ is as stationary points of the Rayleigh quotient

${\displaystyle r(x)={\frac {x^{*}Ax}{x^{*}x}},\qquad x\in \mathbb {C} ^{n}.}$

In particular, the largest eigenvalue ${\displaystyle \lambda _{\max }}$ is the global maximum of ${\displaystyle r}$ and the smallest eigenvalue ${\displaystyle \lambda _{\min }}$ is the global minimum of ${\displaystyle r}$.

Within a low-dimensional subspace ${\displaystyle {\mathcal {L}}}$ of ${\displaystyle \mathbb {C} ^{n}}$ it can be feasible to locate the maximum ${\displaystyle x}$ and minimum ${\displaystyle y}$ of ${\displaystyle r}$. Repeating that for an increasing chain ${\displaystyle {\mathcal {L}}_{1}\subset {\mathcal {L}}_{2}\subset \cdots }$ produces two sequences of vectors: ${\displaystyle x_{1},x_{2},\ldots }$ and ${\displaystyle y_{1},y_{2},\dotsc }$ such that ${\displaystyle x_{j},y_{j}\in {\mathcal {L}}_{j}}$ and

{\displaystyle {\begin{aligned}r(x_{1})&\leqslant r(x_{2})\leqslant \cdots \leqslant \lambda _{\max }\\r(y_{1})&\geqslant r(y_{2})\geqslant \cdots \geqslant \lambda _{\min }\end{aligned}}}

The question then arises how to choose the subspaces so that these sequences converge at optimal rate.

From ${\displaystyle x_{j}}$, the optimal direction in which to seek larger values of ${\displaystyle r}$ is that of the gradient ${\displaystyle \nabla r(x_{j})}$, and likewise from ${\displaystyle y_{j}}$ the optimal direction in which to seek smaller values of ${\displaystyle r}$ is that of the negative gradient ${\displaystyle -\nabla r(y_{j})}$. In general

${\displaystyle \nabla r(x)={\frac {2}{x^{*}x}}(Ax-r(x)x)}$,

so the directions of interest are easy enough to compute in matrix arithmetic, but if one wishes to improve on both ${\displaystyle x_{j}}$ and ${\displaystyle y_{j}}$ then there are two new directions to take into account: ${\displaystyle Ax_{j}}$ and ${\displaystyle Ay_{j};}$ since ${\displaystyle x_{j}}$ and ${\displaystyle y_{j}}$ can be linearly independent vectors (indeed, are close to orthogonal), one cannot in general expect ${\displaystyle Ax_{j}}$ and ${\displaystyle Ay_{j}}$ to be parallel. Is it therefore necessary to increase the dimension of ${\displaystyle {\mathcal {L}}_{j}}$ by ${\displaystyle 2}$ on every step? Not if ${\displaystyle \{{\mathcal {L}}_{j}\}_{j=1}^{m}}$ are taken to be Krylov subspaces, because then ${\displaystyle Az\in {\mathcal {L}}_{j+1}}$ for all ${\displaystyle z\in {\mathcal {L}}_{j},}$ thus in particular for both ${\displaystyle z=x_{j}}$ and ${\displaystyle z=y_{j}.}$.

In other words, we can start with some arbitrary initial vector ${\displaystyle x_{1}=y_{1},}$ construct the vector spaces

${\displaystyle {\mathcal {L}}_{j}=\operatorname {span} (x_{1},Ax_{1},\ldots ,A^{j-1}x_{1})}$

and then seek ${\displaystyle x_{j},y_{j}\in {\mathcal {L}}_{j}}$ such that

${\displaystyle r(x_{j})=\max _{z\in {\mathcal {L}}_{j}}r(z)\qquad {\text{and}}\qquad r(y_{j})=\min _{z\in {\mathcal {L}}_{j}}r(z).}$

Since the ${\displaystyle j}$th power method iterate ${\displaystyle u_{j}}$ belongs to ${\displaystyle {\mathcal {L}}_{j},}$ it follows that an iteration to produce the ${\displaystyle x_{j}}$ and ${\displaystyle y_{j}}$ cannot converge slower than that of the power method, and will achieve more by approximating both eigenvalue extremes. For the subproblem of optimising ${\displaystyle r}$ on some ${\displaystyle {\mathcal {L}}_{j}}$, it is convenient to have an orthonormal basis ${\displaystyle \{v_{1},\ldots ,v_{j}\}}$ for this vector space. Thus we are again led to the problem of iteratively computing such a basis for the sequence of Krylov subspaces.

Convergence and other dynamics

When analysing the dynamics of the algorithm, it is convenient to take the eigenvalues and eigenvectors of ${\displaystyle A}$ as given, even though they are not explicitly known to the user. To fix notation, let ${\displaystyle \lambda _{1}\geqslant \lambda _{2}\geqslant \dotsb \geqslant \lambda _{n}}$ be the eigenvalues (these are known to all be real, and thus possible to order) and let ${\displaystyle z_{1},\dotsc ,z_{n}}$ be an orthonormal set of eigenvectors such that ${\displaystyle Az_{k}=\lambda _{k}z_{k}}$ for all ${\displaystyle k=1,\dotsc ,n}$.

It is also convenient to fix a notation for the coefficients of the initial Lanczos vector ${\displaystyle v_{1}}$ with respect to this eigenbasis; let ${\displaystyle d_{k}=z_{k}^{*}v_{1}}$ for all ${\displaystyle k=1,\dotsc ,n}$, so that ${\displaystyle \textstyle v_{1}=\sum _{k=1}^{n}d_{k}z_{k}}$. A starting vector ${\displaystyle v_{1}}$ depleted of some eigenvalue will delay convergence to the corresponding eigenvalue, and even though this just comes out as a constant factor in the error bounds, depletion remains undesirable. One common technique for avoiding being consistently hit by it is to pick ${\displaystyle v_{1}}$ by first drawing the elements randomly according to the same normal distribution with mean ${\displaystyle 0}$ and then rescale the vector to norm ${\displaystyle 1}$. Prior to the rescaling, this causes the coefficients ${\displaystyle d_{k}}$ to also be independent normally distributed stochastic variables from the same normal distribution (since the change of coordinates is unitary), and after rescaling the vector ${\displaystyle (d_{1},\dotsc ,d_{n})}$ will have a uniform distribution on the unit sphere in ${\displaystyle \mathbb {C} ^{n}}$. This makes it possible to bound the probability that for example ${\displaystyle |d_{1}|<\varepsilon }$.

The fact that the Lanczos algorithm is coordinate-agnostic – operations only look at inner products of vectors, never at individual elements of vectors – makes it easy to construct examples with known eigenstructure to run the algorithm on: make ${\displaystyle A}$ a diagonal matrix with the desired eigenvalues on the diagonal; as long as the starting vector ${\displaystyle v_{1}}$ has enough nonzero elements, the algorithm will output a general tridiagonal symmetric matrix as ${\displaystyle T}$.

Kaniel–Paige convergence theory

After ${\displaystyle m}$ iteration steps of the Lanczos algorithm, ${\displaystyle T}$ is an ${\displaystyle m\times m}$ real symmetric matrix, that similarly to the above has ${\displaystyle m}$ eigenvalues ${\displaystyle \theta _{1}\geqslant \theta _{2}\geqslant \dots \geqslant \theta _{m}.}$ By convergence is primarily understood the convergence of ${\displaystyle \theta _{1}}$ to ${\displaystyle \lambda _{1}}$ (and the symmetrical convergence of ${\displaystyle \theta _{m}}$ to ${\displaystyle \lambda _{n}}$) as ${\displaystyle m}$ grows, and secondarily the convergence of some range ${\displaystyle \theta _{1},\ldots ,\theta _{k}}$ of eigenvalues of ${\displaystyle T}$ to their counterparts ${\displaystyle \lambda _{1},\ldots ,\lambda _{k}}$ of ${\displaystyle A}$. The convergence for the Lanczos algorithm is often orders of magnitude faster than that for the power iteration algorithm.[9]:477

The bounds for ${\displaystyle \theta _{1}}$ come from the above interpretation of eigenvalues as extreme values of the Rayleigh quotient ${\displaystyle r(x)}$. Since ${\displaystyle \lambda _{1}}$ is a priori the maximum of ${\displaystyle r}$ on the whole of ${\displaystyle \mathbb {C} ^{n},}$ whereas ${\displaystyle \theta _{1}}$ is merely the maximum on an ${\displaystyle m}$-dimensional Krylov subspace, we trivially get ${\displaystyle \lambda _{1}\geqslant \theta _{1}}$. Conversely, any point ${\displaystyle x}$ in that Krylov subspace provides a lower bound ${\displaystyle r(x)}$ for ${\displaystyle \theta _{1}}$, so if a point can be exhibited for which ${\displaystyle \lambda _{1}-r(x)}$ is small then this provides a tight bound on ${\displaystyle \theta _{1}}$.

The dimension ${\displaystyle m}$ Krylov subspace is

${\displaystyle \operatorname {span} \left\{v_{1},Av_{1},A^{2}v_{1},\ldots ,A^{m-1}v_{1}\right\},}$

so any element of it can be expressed as ${\displaystyle p(A)v_{1}}$ for some polynomial ${\displaystyle p}$ of degree at most ${\displaystyle m-1}$; the coefficients of that polynomial are simply the coefficients in the linear combination of the vectors ${\displaystyle v_{1},Av_{1},A^{2}v_{1},\ldots ,A^{m-1}v_{1}}$. The polynomial we want will turn out to have real coefficients, but for the moment we should allow also for complex coefficients, and we will write ${\displaystyle p^{*}}$ for the polynomial obtained by complex conjugating all coefficients of ${\displaystyle p}$. In this parametrisation of the Krylov subspace, we have

${\displaystyle r(p(A)v_{1})={\frac {(p(A)v_{1})^{*}Ap(A)v_{1}}{(p(A)v_{1})^{*}p(A)v_{1}}}={\frac {v_{1}^{*}p(A)^{*}Ap(A)v_{1}}{v_{1}^{*}p(A)^{*}p(A)v_{1}}}={\frac {v_{1}^{*}p^{*}(A^{*})Ap(A)v_{1}}{v_{1}^{*}p^{*}(A^{*})p(A)v_{1}}}={\frac {v_{1}^{*}p^{*}(A)Ap(A)v_{1}}{v_{1}^{*}p^{*}(A)p(A)v_{1}}}}$

Using now the expression for ${\displaystyle v_{1}}$ as a linear combination of eigenvectors, we get

${\displaystyle Av_{1}=A\sum _{k=1}^{n}d_{k}z_{k}=\sum _{k=1}^{n}d_{k}\lambda _{k}z_{k}}$

and more generally

${\displaystyle q(A)v_{1}=\sum _{k=1}^{n}d_{k}q(\lambda _{k})z_{k}}$

for any polynomial ${\displaystyle q}$.

Thus

${\displaystyle \lambda _{1}-r(p(A)v_{1})=\lambda _{1}-{\frac {v_{1}^{*}\sum _{k=1}^{n}d_{k}p^{*}(\lambda _{k})\lambda _{k}p(\lambda _{k})z_{k}}{v_{1}^{*}\sum _{k=1}^{n}d_{k}p^{*}(\lambda _{k})p(\lambda _{k})z_{k}}}=\lambda _{1}-{\frac {\sum _{k=1}^{n}|d_{k}|^{2}\lambda _{k}p(\lambda _{k})^{*}p(\lambda _{k})}{\sum _{k=1}^{n}|d_{k}|^{2}p(\lambda _{k})^{*}p(\lambda _{k})}}={\frac {\sum _{k=1}^{n}|d_{k}|^{2}(\lambda _{1}-\lambda _{k})\left|p(\lambda _{k})\right|^{2}}{\sum _{k=1}^{n}|d_{k}|^{2}\left|p(\lambda _{k})\right|^{2}}}.}$

A key difference between numerator and denominator here is that the ${\displaystyle k=1}$ term vanishes in the numerator, but not in the denominator. Thus if one can pick ${\displaystyle p}$ to be large at ${\displaystyle \lambda _{1}}$ but small at all other eigenvalues, one will get a tight bound on the error ${\displaystyle \lambda _{1}-\theta _{1}}$.

Since ${\displaystyle A}$ has many more eigenvalues than ${\displaystyle p}$ has coefficients, this may seem a tall order, but one way to meet it is to use Chebyshev polynomials. Writing ${\displaystyle c_{k}}$ for the degree ${\displaystyle k}$ Chebyshev polynomial of the first kind (that which satisfies ${\displaystyle c_{k}(\cos x)=\cos(kx)}$ for all ${\displaystyle x}$), we have a polynomial which stays in the range ${\displaystyle [-1,1]}$ on the known interval ${\displaystyle [-1,1]}$ but grows rapidly outside it. With some scaling of the argument, we can have it map all eigenvalues except ${\displaystyle \lambda _{1}}$ into ${\displaystyle [-1,1]}$. Let

${\displaystyle p(x)=c_{m-1}\left({\frac {2x-\lambda _{2}-\lambda _{n}}{\lambda _{2}-\lambda _{n}}}\right)}$

(in case ${\displaystyle \lambda _{2}=\lambda _{1}}$, use instead the largest eigenvalue strictly less than ${\displaystyle \lambda _{1}}$), then the maximal value of ${\displaystyle |p(\lambda _{k})|^{2}}$ for ${\displaystyle k\geqslant 2}$ is ${\displaystyle 1}$ and the minimal value is ${\displaystyle 0}$, so

${\displaystyle \lambda _{1}-\theta _{1}\leqslant \lambda _{1}-r(p(A)v_{1})={\frac {\sum _{k=2}^{n}|d_{k}|^{2}(\lambda _{1}-\lambda _{k})|p(\lambda _{k})|^{2}}{\sum _{k=1}^{n}|d_{k}|^{2}|p(\lambda _{k})|^{2}}}\leqslant {\frac {\sum _{k=2}^{n}|d_{k}|^{2}(\lambda _{1}-\lambda _{k})}{|d_{1}|^{2}|p(\lambda _{1})|^{2}}}\leqslant {\frac {(\lambda _{1}-\lambda _{n})\sum _{k=2}^{n}|d_{k}|^{2}}{|p(\lambda _{1})|^{2}|d_{1}|^{2}}}.}$

Furthermore

${\displaystyle p(\lambda _{1})=c_{m-1}\left({\frac {2\lambda _{1}-\lambda _{2}-\lambda _{n}}{\lambda _{2}-\lambda _{n}}}\right)=c_{m-1}\left(2{\frac {\lambda _{1}-\lambda _{2}}{\lambda _{2}-\lambda _{n}}}+1\right);}$

the quantity

${\displaystyle \rho ={\frac {\lambda _{1}-\lambda _{2}}{\lambda _{2}-\lambda _{n}}}}$

(i.e., the ratio of the first eigengap to the diameter of the rest of the spectrum) is thus of key importance for the convergence rate here. Also writing

${\displaystyle R=e^{\operatorname {arcosh} (1+2\rho )}=1+2\rho +2{\sqrt {\rho ^{2}+\rho }},}$

we may conclude that

{\displaystyle {\begin{aligned}\lambda _{1}-\theta _{1}&\leqslant {\frac {(\lambda _{1}-\lambda _{n})\left(1-|d_{1}|^{2}\right)}{c_{m-1}(2\rho +1)^{2}|d_{1}|^{2}}}\\[6pt]&={\frac {1-|d_{1}|^{2}}{|d_{1}|^{2}}}(\lambda _{1}-\lambda _{n}){\frac {1}{\cosh ^{2}((m-1)\operatorname {arcosh} (1+2\rho ))}}\\[6pt]&={\frac {1-|d_{1}|^{2}}{|d_{1}|^{2}}}(\lambda _{1}-\lambda _{n}){\frac {4}{\left(R^{m-1}+R^{-(m-1)}\right)^{2}}}\\[6pt]&\leqslant 4{\frac {1-|d_{1}|^{2}}{|d_{1}|^{2}}}(\lambda _{1}-\lambda _{n})R^{-2(m-1)}\end{aligned}}}

The convergence rate is thus controlled chiefly by ${\displaystyle R}$, since this bound shrinks by a factor ${\displaystyle R^{-2}}$ for each extra iteration.

For comparison, one may consider how the convergence rate of the power method depends on ${\displaystyle \rho }$, but since the power method primarily is sensitive to the quotient between absolute values of the eigenvalues, we need ${\displaystyle |\lambda _{n}|\leqslant |\lambda _{2}|}$ for the eigengap between ${\displaystyle \lambda _{1}}$ and ${\displaystyle \lambda _{2}}$ to be the dominant one. Under that constraint, the case that most favours the power method is that ${\displaystyle \lambda _{n}=-\lambda _{2}}$, so consider that. Late in the power method, the iteration vector:

${\displaystyle u=(1-t^{2})^{1/2}z_{1}+tz_{2}\approx z_{1}+tz_{2},}$[note 1]

where each new iteration effectively multiplies the ${\displaystyle z_{2}}$-amplitude ${\displaystyle t}$ by

${\displaystyle {\frac {\lambda _{2}}{\lambda _{1}}}={\frac {\lambda _{2}}{\lambda _{2}+(\lambda _{1}-\lambda _{2})}}={\frac {1}{1+{\frac {\lambda _{1}-\lambda _{2}}{\lambda _{2}}}}}={\frac {1}{1+2\rho }}.}$

The estimate of the largest eigenvalue is then

${\displaystyle u^{*}Au=(1-t^{2})\lambda _{1}+t^{2}\lambda _{2},}$

so the above bound for the Lanczos algorithm convergence rate should be compared to

${\displaystyle \lambda _{1}-u^{*}Au=(\lambda _{1}-\lambda _{2})t^{2},}$

which shrinks by a factor of ${\displaystyle (1+2\rho )^{-2}}$ for each iteration. The difference thus boils down to that between ${\displaystyle 1+2\rho }$ and ${\displaystyle R=1+2\rho +2{\sqrt {\rho ^{2}+\rho }}}$. In the ${\displaystyle \rho \gg 1}$ region, the latter is more like ${\displaystyle 1+4\rho }$, and performs like the power method would with an eigengap twice as large; a notable improvement. The more challenging case is however that of ${\displaystyle \rho \ll 1,}$ in which ${\displaystyle R\approx 1+2{\sqrt {\rho }}}$ is an even larger improvement on the eigengap; the ${\displaystyle \rho \gg 1}$ region is where the Lanczos algorithm convergence-wise makes the smallest improvement on the power method.

Numerical stability

Stability means how much the algorithm will be affected (i.e. will it produce the approximate result close to the original one) if there are small numerical errors introduced and accumulated. Numerical stability is the central criterion for judging the usefulness of implementing an algorithm on a computer with roundoff.

For the Lanczos algorithm, it can be proved that with exact arithmetic, the set of vectors ${\displaystyle v_{1},v_{2},\cdots ,v_{m+1}}$ constructs an orthonormal basis, and the eigenvalues/vectors solved are good approximations to those of the original matrix. However, in practice (as the calculations are performed in floating point arithmetic where inaccuracy is inevitable), the orthogonality is quickly lost and in some cases the new vector could even be linearly dependent on the set that is already constructed. As a result, some of the eigenvalues of the resultant tridiagonal matrix may not be approximations to the original matrix. Therefore, the Lanczos algorithm is not very stable.

Users of this algorithm must be able to find and remove those "spurious" eigenvalues. Practical implementations of the Lanczos algorithm go in three directions to fight this stability issue:[6][7]

1. Prevent the loss of orthogonality,
2. Recover the orthogonality after the basis is generated.
3. After the good and "spurious" eigenvalues are all identified, remove the spurious ones.

Variations

Variations on the Lanczos algorithm exist where the vectors involved are tall, narrow matrices instead of vectors and the normalizing constants are small square matrices. These are called "block" Lanczos algorithms and can be much faster on computers with large numbers of registers and long memory-fetch times.

Many implementations of the Lanczos algorithm restart after a certain number of iterations. One of the most influential restarted variations is the implicitly restarted Lanczos method,[10] which is implemented in ARPACK.[11] This has led into a number of other restarted variations such as restarted Lanczos bidiagonalization.[12] Another successful restarted variation is the Thick-Restart Lanczos method,[13] which has been implemented in a software package called TRLan.[14]

Nullspace over a finite field

In 1995, Peter Montgomery published an algorithm, based on the Lanczos algorithm, for finding elements of the nullspace of a large sparse matrix over GF(2); since the set of people interested in large sparse matrices over finite fields and the set of people interested in large eigenvalue problems scarcely overlap, this is often also called the block Lanczos algorithm without causing unreasonable confusion.

Applications

Lanczos algorithms are very attractive because the multiplication by ${\displaystyle A\,}$ is the only large-scale linear operation. Since weighted-term text retrieval engines implement just this operation, the Lanczos algorithm can be applied efficiently to text documents (see Latent Semantic Indexing). Eigenvectors are also important for large-scale ranking methods such as the HITS algorithm developed by Jon Kleinberg, or the PageRank algorithm used by Google.

Lanczos algorithms are also used in Condensed Matter Physics as a method for solving Hamiltonians of strongly correlated electron systems,[15] as well as in shell model codes in nuclear physics.[16]

Implementations

The NAG Library contains several routines[17] for the solution of large scale linear systems and eigenproblems which use the Lanczos algorithm.

MATLAB and GNU Octave come with ARPACK built-in. Both stored and implicit matrices can be analyzed through the eigs() function (Matlab/Octave).

A Matlab implementation of the Lanczos algorithm (note precision issues) is available as a part of the Gaussian Belief Propagation Matlab Package. The GraphLab[18] collaborative filtering library incorporates a large scale parallel implementation of the Lanczos algorithm (in C++) for multicore.

The PRIMME library also implements a Lanczos like algorithm.

Notes

1. The coefficients need not both be real, but the phase is of little importance. Nor need the composants for other eigenvectors have completely disappeared, but they shrink at least as fast as that for ${\displaystyle z_{2}}$, so ${\displaystyle u\approx z_{1}+tz_{2}}$ describes the worst case.

References

1. Lanczos, C. (1950). "An iteration method for the solution of the eigenvalue problem of linear differential and integral operators" (PDF). J. Res. Nat'l Bur. STD. 45 (4): 255–282. doi:10.6028/jres.045.026.
2. Ojalvo, I. U.; Newman, M. (1970). "Vibration modes of large structures by an automatic matrix-reduction method". AIAA Journal. 8 (7): 1234–1239. Bibcode:1970AIAAJ...8.1234N. doi:10.2514/3.5878.
3. Paige, C. C. (1971). The computation of eigenvalues and eigenvectors of very large sparse matrices (Ph.D. thesis). U. of London. OCLC 654214109.
4. Paige, C. C. (1972). "Computational Variants of the Lanczos Method for the Eigenproblem". J. Inst. Maths Applics. 10 (3): 373–381. doi:10.1093/imamat/10.3.373.
5. Ojalvo, I. U. (1988). "Origins and advantages of Lanczos vectors for large dynamic systems". Proc. 6th Modal Analysis Conference (IMAC), Kissimmee, FL. pp. 489–494.
6. Cullum; Willoughby. Lanczos Algorithms for Large Symmetric Eigenvalue Computations. 1. ISBN 0-8176-3058-9.
7. Yousef Saad (1992-06-22). Numerical Methods for Large Eigenvalue Problems. ISBN 0-470-21820-7.
8. Coakley, Ed S.; Rokhlin, Vladimir (2013). "A fast divide-and-conquer algorithm for computing the spectra of real symmetric tridiagonal matrices". Applied and Computational Harmonic Analysis. 34 (3): 379–414. doi:10.1016/j.acha.2012.06.003.
9. Golub, Gene H.; Van Loan, Charles F. (1996). Matrix computations (3. ed.). Baltimore: Johns Hopkins Univ. Press. ISBN 0-8018-5413-X.
10. D. Calvetti; L. Reichel; D.C. Sorensen (1994). "An Implicitly Restarted Lanczos Method for Large Symmetric Eigenvalue Problems". Electronic Transactions on Numerical Analysis. 2: 1–21.
11. R. B. Lehoucq; D. C. Sorensen; C. Yang (1998). ARPACK Users Guide: Solution of Large-Scale Eigenvalue Problems with Implicitly Restarted Arnoldi Methods. SIAM. doi:10.1137/1.9780898719628. ISBN 978-0-89871-407-4.
12. E. Kokiopoulou; C. Bekas; E. Gallopoulos (2004). "Computing smallest singular triplets with implicitly restarted Lanczos bidiagonalization" (PDF). Appl. Numer. Math. 49: 39–61. doi:10.1016/j.apnum.2003.11.011.
13. Kesheng Wu; Horst Simon (2000). "Thick-Restart Lanczos Method for Large Symmetric Eigenvalue Problems". SIAM Journal on Matrix Analysis and Applications. SIAM. 22 (2): 602–616. doi:10.1137/S0895479898334605.
14. Kesheng Wu; Horst Simon (2001). "TRLan software package".
15. Chen, HY; Atkinson, W.A.; Wortis, R. (July 2011). "Disorder-induced zero-bias anomaly in the Anderson-Hubbard model: Numerical and analytical calculations". Physical Review B. 84 (4): 045113. arXiv:1012.1031. Bibcode:2011PhRvB..84d5113C. doi:10.1103/PhysRevB.84.045113.
16. Shimizu, Noritaka (21 October 2013). "Nuclear shell-model code for massive parallel computation, "KSHELL"". arXiv:1310.5431 [nucl-th].
17. The Numerical Algorithms Group. "Keyword Index: Lanczos". NAG Library Manual, Mark 23. Retrieved 2012-02-09.
18. GraphLab Archived 2011-03-14 at the Wayback Machine