Fundamentals / Numerical mathematics / Numerical linear algebra

Arnoldi iteration and GMRES

Construct an orthonormal basis for a nonsymmetric operator and use a small least-squares problem to choose an approximation.

From first principles

Project a large operator onto successive Krylov directions

For \(Ax=b\), start with residual \(r_0=b-Ax_0\ne0\). Choose the first basis vector as \(v_1=r_0/\beta\), where \(\beta=\|r_0\|_2\). Repeated matrix products generate a search space, but their columns can become nearly parallel. At step \(j\), remove previously resolved components of \(Av_j\) before normalizing the remainder,

\[h_{ij}=v_i^TAv_j,\]
\[w=Av_j-\sum_{i=1}^j h_{ij}v_i,\]
\[h_{j+1,j}=\|w\|_2 .\]

If \(h_{j+1,j}>0\), take \(v_{j+1}=w/h_{j+1,j}\). The resulting Arnoldi identity \(AV_k=V_{k+1}\bar H_k\) expresses each large product using a small upper-Hessenberg matrix. A correction \(V_ky\) gives the residual norm

\[\|r_0-AV_ky\|_2=\|\beta e_1-\bar H_k y\|_2 .\]

Orthonormality justifies the equality. GMRES solves the smaller least-squares problem to minimize the actual residual over this search space. When the new norm is zero the subspace is already invariant, and no further independent direction is available through another ordinary Arnoldi step.

Background · Krylov subspace
\[\mathcal K_k(A,b)=\operatorname{span}(b,Ab,\ldots,A^{k-1}b)\]

The starting vector determines which parts of the spectrum are visible. Orthogonalisation avoids storing nearly dependent raw powers.

Derivation and applications

Calculate exactly when the first GMRES step stalls

For one Krylov step the only available correction is a multiple of the initial residual \(r=b-Ax\). The resulting change in the residual is parallel to \(Ar\). Assume a real nonsingular \(A\) and \(r\ne0\), which guarantees \(Ar\ne0\). To choose the coefficient \(\alpha\), expand the squared residual norm,

\[\|r-\alpha Ar\|_2^2=r^Tr-2\alpha(Ar)^Tr+\alpha^2\|Ar\|_2^2 .\]

The derivative vanishes at the coefficient of the orthogonal projection of \(r\) onto \(Ar\). Hence the new residual is perpendicular to the direction in which it was allowed to change,

\[\alpha_*=\frac{(Ar)^Tr}{\|Ar\|_2^2},\qquad (Ar)^T(r-\alpha_*Ar)=0 .\]

Let \(\theta\) denote the angle between \(r\) and \(Ar\). At the minimum the squared length removed is exactly the squared length of that projection. The remaining fraction of residual is

\[\frac{\|r_{\rm new}\|}{\|r\|}=\sqrt{1-\frac{[(Ar)^Tr]^2}{\|Ar\|^2\|r\|^2}}=|\sin\theta|.\]

Thus equal or opposite directions allow an exact one-step solve, while perpendicular directions deliver no change. This is purely geometric and applies without symmetry. It also clarifies why restarting after one step can be costly: later basis vectors could expose a direction inaccessible on the first line.

Worked example

Compute the residual reduction for a shear

Use \(A=\left(\begin{smallmatrix}1&2\\0&1\end{smallmatrix}\right)\) and \(r=(0,1)^T\). Then \(Ar=(2,1)^T\), \(\alpha_*=1/5\), and \(r_{\rm new}=(-0.4,0.8)^T\). Its norm is

\[\sqrt{0.8}=0.894.\]

The dot product with \(Ar\) is \(-0.8+0.8=0\), an independent check that the selected coefficient minimizes the residual along this line.

Second application

Detect stagnation despite a nonsingular operator

Take \(A=\operatorname{diag}(2,-1)\) and \(r=(1,\sqrt2)^T\). The dot product \(r^TAr=2-2=0\) forces the first coefficient to zero. A second direction completes a two-dimensional space because \(Ar=(2,-\sqrt2)^T\) is independent of \(r\). In fact \(A^{-1}r=(0.5,-\sqrt2)^T=-0.5r+0.5Ar\). The two-direction correction solves the problem exactly although a one-step restart would repeat the same state.

A residual as a polynomial

Consider a square nonsingular matrix and an initial residual \(r_0=b-Ax_0\). A correction in the span of \(r_0,Ar_0,\ldots,A^{k-1}r_0\) is a polynomial in \(A\) applied to \(r_0\). After subtracting the action of \(A\), the new residual is \(p_k(A)r_0\) with \(p_k(0)=1\). This constraint matters because the zero polynomial would certify convergence before the calculation began. Generalised minimal residual iteration, or GMRES, minimises the Euclidean norm over all such residuals. The spaces are nested, so the exact-arithmetic residual norms cannot increase during a cycle.

Replacing large products by small coordinates

Start with \(v_1=r_0/\beta\), where \(\beta=\|r_0\|_2\). For each new direction form \(w=Av_j\), subtract its projections onto the existing orthonormal columns, and normalise what remains. Each projection coefficient occupies one row of column \(j\) of a small matrix. The final normalising length occupies its first subdiagonal. This Arnoldi construction gives

\[AV_k=V_{k+1}\bar H_k.\]

If the length vanishes, the current subspace is invariant and no further normalisation is possible.

\[\|b-A(x_0+V_ky)\|_2=\|V_{k+1}(\beta e_1-\bar H_ky)\|_2=\|\beta e_1-\bar H_ky\|_2.\]

The second equality uses orthonormality. Solve this small rectangular least-squares problem, for example by updating triangular factors using plane rotations. The resulting residual is orthogonal to the range of \(AV_k\). Repeated projection may be necessary when rounding spoils orthogonality. A freshly calculated physical residual can test the small model's estimate before reporting convergence.

One eigenvalue and two directions

Take \(A=\left(\begin{smallmatrix}1&4\\0&1\end{smallmatrix}\right)\), \(x_0=0\), \(b=e_2\). The first correction is \(\alpha e_2\), so the squared residual is \(16\alpha^2+(1-\alpha)^2\). Differentiation gives \(\alpha=1/17\) and length \(4/\sqrt{17}\), about 0.9701. Almost the entire initial residual survives despite every eigenvalue being one. The second direction comes from the component of \(Ae_2\) perpendicular to \(e_2\), namely \(4e_1\). With both directions available the exact solution \((-4,1)^T\) is accessible, and its residual vanishes.

For a diagonal matrix equal to the identity, a single step would suffice for every right-hand side. Here a nonzero off-diagonal entry couples two coordinates and the minimal polynomial is \((z-1)^2\). Counting distinct eigenvalues alone misses that coupling.

Paying for a long memory

Each new direction needs storage and projections against earlier directions. Restarting after a fixed number releases memory, but discards those directions. A new cycle still starts from the best current iterate. It lacks the previous cycle's simultaneous freedom to alter its old coefficients. Record matrix-vector products and the residual after each restart when comparing costs. On the example, two directions retained together already achieve the exact answer, providing a direct check on a proposed implementation.

Read a preconditioned residual

Left preconditioning with \(M^{-1}\) makes GMRES minimise \(\|M^{-1}(b-Ax)\|\) instead. If \(M=\operatorname{diag}(1,1000)\), a physical residual \((0,1)^T\) has preconditioned norm 0.001. A small number in the stopping display could therefore leave the second physical balance comparatively inaccurate. Right preconditioning solves \(AM^{-1}y=b\), then forms \(x=M^{-1}y\); for exact preconditioner actions its minimisation still uses the original residual. Compare work and physically meaningful residuals when assessing either choice, especially if the equations use different units.

How restarting can erase a necessary direction

GMRES minimises the full residual norm over its current correction space. A one-step restart retains only the first correction direction generated from the new residual. If that direction makes no angle with the gradient of the residual objective in the appropriate sense, progress can cease even for an invertible, perfectly conditioned matrix. To see the geometry, suppose the current residual is \(r\). The one-dimensional trial residual is \(r-\alpha Ar\). Minimising its squared norm for real arithmetic yields

\[\alpha=(Ar)^Tr/\|Ar\|^2.\]

Thus no reduction occurs when \(Ar\) is perpendicular to \(r\). Restarting immediately recreates precisely the same subproblem.

Unrestarted GMRES can still add \(Ar\) and further powers to its Krylov space. In exact arithmetic it can therefore escape one-step stagnation. This distinction matters for storage allocation: reducing the basis length can change the convergence mechanism itself. Merely multiplying the allowed number of restart cycles cannot recover directions if every cycle begins and ends with the same residual. Conversely increasing the restart length helps only if the additional space contains directions that produce a lower residual.

Compare restart lengths for a quarter-turn operator

Set \(A=\left(\begin{smallmatrix}0&-1\\1&0\end{smallmatrix}\right)\) and \(b=(1,0)^T\), beginning at zero. Its transpose times itself is the identity, so its two-norm condition number is one. Yet \(Ab=(0,1)^T\) is perpendicular to the initial residual \(b\). The residual after trial step \(\alpha b\) is \((1,-\alpha)^T\), whose squared length is \(1+\alpha^2\). The best step is exactly zero. GMRES restarted every step thus leaves the residual norm at one forever.

With a two-vector basis use corrections \(x=\alpha b+\beta Ab=(\alpha,\beta)^T\). The residual is \((1+\beta,-\alpha)^T\), which vanishes for \(\alpha=0,\beta=-1\). The exact solution is reached. In polynomial language no degree-one real polynomial satisfying \(p(0)=1\) can vanish at both eigenvalues \(+i,-i\). The degree-two choice \(p(z)=1+z^2\) does so because \(A^2=-I\). Both formulations explain the same measurement without attributing the failure to singularity or loss of precision.

For a nonsingular real skew-symmetric matrix the one-step numerator vanishes for every real \(r\), since a scalar \(r^TAr\) equals its own negative after transposition. This family therefore offers a repeatable stress test for short-restart implementations. A preconditioner or a shift that alters the search geometry can change the result, but any claimed gain should be checked using the residual of the original equations and a comparable count of matrix-vector products.

There is also a simple residual recomputation check at convergence: for the two-step state \((0,-1)^T\), multiplying by the original matrix gives \((1,0)^T\) exactly. If a code reports the same state after one iteration, it has either used a different search direction or mislabelled its iteration count. Exposing the current basis length alongside the total matrix-vector count makes a restart experiment easier to reproduce.

For complex arithmetic, use the real or complex least-squares minimisation appropriate to the actual correction space; the perpendicularity argument above assumes real data.

Change parameters · Explore the worked calculation

Change one input at a time and compare the recalculated curves with the argument above. The browser evaluates this small model locally; the accompanying numerical values state its assumptions and reference checks. Reset restores the reference inputs, and the data can be downloaded as CSV.

Study the full derivation

When stable eigenvalues allow large transient growth · Matrix computations and spectral accuracy

Two damped states exchange energy in only one direction. Its eigenvalues predict ultimate decay, while a short-time response can grow by a large factor. Compute the matrix exponential, its gain and a resolvent-based sensitivity check.