# Lanczos algorithm

(Redirected from Lanczos iteration)

The Lanczos algorithm is a direct algorithm devised by Cornelius Lanczos[1] that is an adaptation of power methods to find the most useful eigenvalues and eigenvectors of an ${\displaystyle n}$th-order linear system with a limited number of operations, ${\displaystyle m}$, where ${\displaystyle m}$ is much smaller than ${\displaystyle n}$. Although computationally efficient in principle, the method as initially formulated was not useful, due to its numerical instability. In 1970, Ojalvo and Newman[2] showed how to make the method numerically stable and applied it to the solution of very large engineering structures subjected to dynamic loading. This was achieved using a method for purifying the vectors 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,[3][4] who also provided an error analysis. In 1988, Ojalvo[5] produced a more detailed history of this algorithm and an efficient eigenvalue error test. Currently, the method is widely used in a variety of technical fields and has seen a number of variations.

## 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. First observe that when ${\displaystyle T}$ is ${\displaystyle n\times n}$, it is similar to ${\displaystyle A}$: if ${\displaystyle \lambda }$ is an eigenvalue of ${\displaystyle T}$ then it is also 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 that the algorithm primarily performs is rather tridiagonalization of a matrix, but for that the numerically stable Householder transformations have been favoured ever since the 1950s, and 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 rather 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 rather 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}'/\lVert u_{j+1}'\rVert }$.
• 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}'/\lVert u_{j+1}'\rVert }$ and ${\displaystyle v_{j+1}=w_{j+1}/\lVert w_{j+1}\rVert }$,
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}=\lVert u_{j+1}'\rVert u_{j+1}=u_{j+1}'=w_{j+1}+\sum _{k=1}^{j}g_{k,j}v_{k}=\lVert w_{j+1}\rVert 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}=\lVert w_{j+1}\rVert }$.
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}=\lVert w_{j+1}\rVert }$ 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}=\lVert w_{j+1}\rVert v_{j+1}^{*}v_{j+1}=\lVert w_{j+1}\rVert }$. Because the power iteration vectors ${\displaystyle u_{j}}$ that were eliminated from this recursion satisfy ${\displaystyle u_{j}\in \operatorname {span} (v_{1},\dotsc ,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},\dotsc ,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},\dotsc ,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},\dotsc ,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^{*}=(V^{*}AV)^{*}=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}}}$ for ${\displaystyle 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 \dotsb }$ produces two sequences ${\displaystyle x_{1},x_{2},\dotsc }$ and ${\displaystyle y_{1},y_{2},\dotsc }$ of vectors such that ${\displaystyle x_{j},y_{j}\in {\mathcal {L}}_{j}}$ for all ${\displaystyle j}$, ${\displaystyle r(x_{1})\leqslant r(x_{2})\leqslant \dotsb \leqslant \lambda _{\max }}$, and ${\displaystyle r(y_{1})\geqslant r(y_{2})\geqslant \dotsb \geqslant \lambda _{\min }}$. 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},\dotsc ,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)}$ and ${\displaystyle 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},\dotsc ,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.

## 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.[citation needed]

## 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]

## Implementations

The NAG Library contains several routines[16] 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[17] 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.

## References

1. ^ Lanczos, C. "An iteration method for the solution of the eigenvalue problem of linear differential and integral operators", J. Res. Nat’l Bur. Std. 45, 255-282 (1950).
2. ^ Ojalvo, I. U. and Newman, M., "Vibration modes of large structures by an automatic matrix-reduction method", AIAA J., 8 (7), 1234–1239 (1970).
3. ^ Paige, C. C., "The computation of eigenvalues and eigenvectors of very large sparse matrices", the U. of London Ph.D. thesis (1971).
4. ^ Paige, C. C., "Computational variants of the Lanczos method for the eigenproblem", J. Inst. Maths Applics 10, 373–381 (1972).
5. ^ Ojalvo, I. U., "Origins and advantages of Lanczos vectors for large dynamic systems", Proc. 6th Modal Analysis Conference (IMAC), Kissimmee, FL, 489–494 (1988).
6. ^ a b Cullum; Willoughby. Lanczos Algorithms for Large Symmetric Eigenvalue Computations. 1. ISBN 0-8176-3058-9.
7. ^ a b
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: 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.
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). doi:10.1103/PhysRevB.84.045113.
16. ^ The Numerical Algorithms Group. "Keyword Index: Lanczos". NAG Library Manual, Mark 23. Retrieved 2012-02-09.
17. ^ GraphLab Archived 2011-03-14 at the Wayback Machine.