Eigenvalue and SVD algorithms (QR algorithm, Golub–Kahan) and Krylov methods
Before this lesson: lesson 05 (eigenvalues, power iteration), lesson 06 (spectral theorem, Rayleigh quotient), lesson 07 (positive definite matrices), lesson 12 (QR) and lesson 13 (floating point and conditioning). Time: about 90 minutes, plus the notebook.
Why this matters #
Nobody computes eigenvalues as the roots of . Polynomial roots are very
sensitive to rounding in the coefficients, and for there is no formula for them in
radicals (Abel–Ruffini). So every eigenvalue algorithm iterates. Two families cover practice.
Dense methods (the QR algorithm, Golub–Kahan for the SVD) find all eigenvalues of a matrix you
can store, in operations; they run inside np.linalg.eig, eigh and svd. Krylov
methods only need the product . They find a few eigenvalues or solve for
sparse or implicit matrices with millions of unknowns: the pressure-Poisson step of a fluid
solver, the top eigenvalues of a network Hessian. CG also explains why the condition number
decides how long such a solve takes.
1. Predict first #
2. The picture #
Power iteration, two upgrades. Power iteration (lesson 05) repeats and finds the dominant eigenvector at rate per step. Two ideas improve it.
- Change the matrix. has the same eigenvectors as and eigenvalues . The eigenvalue closest to the shift becomes the dominant one. This is inverse iteration. If you update at every step with the current estimate, you get Rayleigh quotient iteration.
- Iterate many vectors at once. Multiply an orthonormal block of vectors by and re-orthonormalize it (QR). The block converges to the span of the top eigenvectors. With this is the QR algorithm.
Move the shift . All three methods start from the same vector of a symmetric matrix. Power iteration falls at the slow rate (0.96 for the second spectrum). Inverse iteration finds the eigenvalue closest to (the blue dot on the strip) at the rate : put near an eigenvalue and the line gets steep; put it halfway between two and it crawls. Rayleigh quotient iteration updates its shift every step and needs only a few.
A symmetric matrix has eigenvalues . Inverse iteration uses the fixed shift . Which eigenvalue does it find, and how fast?
Inverse iteration finds the eigenvalue closest to : . The rate is the distance to the closest one divided by the distance to the next closest. The next closest is (), not (). So the ratio is . Without a shift () it would find .
Keep every vector. Power iteration keeps only the last vector and throws away . A Krylov method keeps all of them and picks the best combination. Every vector in their span is for a polynomial of degree at most . Power iteration always uses ; a Krylov method chooses the best for the task. "Best" can be made precise, and that gives the convergence theory below.
3. Definitions and main results #
Inverse iteration and Rayleigh quotient iteration #
Inverse iteration with shift : solve , set . Factor once (LU), then each step costs two triangular solves, ; never form the inverse. Let be the eigenvalue closest to and the next closest. The vector converges to with error : a good shift gives a tiny ratio. The system is nearly singular when , but this is harmless: the large error in points along , which is the direction we want.
Rayleigh quotient iteration (RQI): use the shift (with ), updated every step. For symmetric it converges cubically:
- If , the Rayleigh quotient is accurate to (lesson 06).
- One inverse-iteration step with a shift error multiplies the error by .
- So : the number of correct digits roughly triples per step.
The price is a new factorization at every step. For non-symmetric the rate is quadratic.
The QR algorithm #
Two vectors at a time, in words. Take . Its eigenvectors are (eigenvalue 3) and (eigenvalue 1). Start with the two vectors .
- Power step. Multiply both by : and .
- Re-orthonormalize with Gram–Schmidt: and . Steps 1 and 2 together are one QR factorization of .
- Repeat. The first vector does plain power iteration, so it turns toward the dominant eigenvector ; the angle error shrinks by about per step.
- The second vector must stay orthogonal to the first. In it has only one place to go: the other eigenvector , up to sign.
- So tends to the eigenvector matrix, and tends to .
In dimensions the first vectors do power iteration on a -dimensional subspace, so their span tends to the span of the top eigenvectors. The QR algorithm does not store these vectors. It updates the matrix directly, as the theorem shows.
Theorem (the QR algorithm is simultaneous power iteration) #
Let and . Then (a) , and (b) .
Proof.
- From : , so . Repeating this from gives (a). Each step is an orthogonal similarity: same eigenvalues, and a symmetric stays symmetric.
- For (b), use induction. : . Assume . By (a), . So .
- is upper triangular (with a nonzero diagonal if is nonsingular), so (b) is a QR factorization of . The first columns of are an orthonormal basis of the span of the first columns of , that is, of : power iteration on a -dimensional subspace.
Convergence. Let be symmetric with , and let all leading principal submatrices of its eigenvector matrix be nonsingular (true for almost every ). Then tends to , ordered by decreasing , and tends to the eigenvectors (up to signs). The entry decays like : linear convergence, slow when two eigenvalues are close in modulus. For a real non-symmetric the limit is the real Schur form: upper triangular, with blocks for complex-conjugate pairs.
The hidden inverse iteration. For symmetric , invert (b): , and since is symmetric, with lower triangular. Its last column gives . So the last column of runs inverse iteration. This is why a shift taken from the bottom-right corner works so well.
Answers to section 1, question 2. The off-diagonal entry shrinks by per step, asymptotically (section 4 shows ). For nothing happens: , , so . The eigenvalues have equal modulus, and the ratio is 1.
A symmetric matrix has eigenvalues . In the unshifted QR algorithm, by what factor does the entry of shrink per step (asymptotically)?
Entry decays like . For this is . Entry also decays at the rate . Only equal moduli (ratio 1) stop the unshifted algorithm.
The practical eigenvalue pipeline #
- Reduce once to Hessenberg form. Householder reflections give with zero below the first subdiagonal, in about flops. A symmetric becomes tridiagonal (about flops). Triangular form cannot be reached in a finite number of steps (for it would give the eigenvalues in closed form, see Abel–Ruffini); Hessenberg is the closest form one can reach.
- QR steps keep the form and are cheap. If is Hessenberg, then and are Hessenberg too. One step costs with Givens rotations instead of ; on a tridiagonal matrix, .
- Shifts. , . This is still a similarity: . The Rayleigh shift is, for symmetric , RQI on the last column (hidden inverse iteration). It fails on (, no progress). The Wilkinson shift is the eigenvalue of the trailing block that is closer to . For symmetric tridiagonal matrices it always converges (Wilkinson, 1968), at least quadratically and in practice cubically.
- Deflation. When , set it to 0. Then is an eigenvalue; continue on the leading block.
- Real non-symmetric matrices have complex pairs. The Francis double-shift step uses the two eigenvalues of the trailing block as shifts in one real step, applied implicitly ("bulge chasing").
Press Run, then change the shift. The chart follows the subdiagonal entries of on a log scale, and the heat map shows (stronger colour = larger ). Without a shift each entry decays at its own rate (dashed) and the whole run takes about 100 steps. With the Rayleigh or Wilkinson shift the corner entry drops below in a few steps, the block deflates (dashed frame), and the next corner starts: all four eigenvalues take 13 steps with the Rayleigh shift and 7 with the Wilkinson shift. Try the zero-diagonal matrix: the Rayleigh shift is 0, so the corner does not move until rounding errors break the symmetry (the first eigenvalue deflates after about 37 steps); the Wilkinson shift finishes in 8.
The SVD pipeline: Golub–Kahan #
We want orthogonal with diagonal. The SVD is not a similarity ( and can differ), so a finite procedure can reach more than Hessenberg form: a bidiagonal matrix , with nonzeros only on the diagonal and the first superdiagonal. Golub–Kahan bidiagonalization does this with Householder reflections from the left and from the right: .
- Why this is the right form. is tridiagonal: Golub–Kahan tridiagonalizes without forming it.
- Phase 2. The singular values of are computed by an implicitly shifted QR iteration on itself, or by divide and conquer.
- Why not . Forming squares the condition number (lesson 13). Its computed eigenvalues have absolute errors of about , so every singular value below about is lost (section 5 shows coming out as ).
Golub–Kahan step by step, and which LAPACK routine NumPy calls
For the reflections alternate: from the left, zero column below the diagonal; from the right, zero row to the right of the superdiagonal. For a matrix ( = nonzero):
The right reflection acts on columns 2–3 only, so it does not refill column 1. The cost is about flops. For it is cheaper to compute first and bidiagonalize the matrix (about flops).
Phase 2 is either the implicitly shifted QR iteration on (Golub–Kahan–Reinsch; LAPACK driver
gesvd) or divide and conquer (gesdd, the NumPy and SciPy default). So NumPy's SVD is
Golub–Kahan bidiagonalization followed by divide and conquer, not a QR iteration; the QR driver is
available as scipy.linalg.svd(..., lapack_driver="gesvd").
For eigenvalues: np.linalg.eig calls LAPACK geev (Hessenberg reduction, then Francis QR);
np.linalg.eigh calls syevd (tridiagonal reduction, then divide and conquer);
scipy.linalg.eigh uses syevr (tridiagonal reduction, then the MRRR method) by default. The
QR algorithm is the core for non-symmetric matrices; for symmetric ones it is one of several
choices after the reduction.
Krylov subspaces and the Arnoldi relation #
The Krylov subspace of and is
Building it needs only matrix-vector products.
Why the plain basis is bad. The vectors are the iterates of power iteration. So they all turn toward the dominant eigenvector, and after a few steps they are almost parallel. A basis of almost parallel vectors is extremely ill-conditioned: small rounding errors in the vectors change the coefficients completely.
Move , then switch to the Hessenberg view. Top: the condition number of the plain basis (each vector scaled to length 1) grows by about 6 times per step and comes close to (numerically singular) by ; the Arnoldi basis spans the same space and keeps . Bottom: the angle between and the top eigenvector falls toward 0. In the Hessenberg view, press Next step: each Arnoldi step adds one column to . Switch to a symmetric matrix and the entries above the first superdiagonal become 0.
Arnoldi builds an orthonormal basis of the same space, one vector at a time. It orthogonalizes each new vector against the old ones (modified Gram–Schmidt, lesson 12):
; for : ; for : , ; then , .
The loop as equations, for . Rearrange each step: what was subtracted plus what is left gives back .
- Step : .
- Step : .
Put the two equations side by side as columns:
The 0 in the bottom-left corner is there because needs only and . In general needs only , so is zero below its first subdiagonal: it is upper Hessenberg.
Theorem (Arnoldi relation) #
If no is zero, the columns of () are an orthonormal basis of , and
with of size , of size upper Hessenberg, and its top block.
Proof.
- Step of the loop, rearranged, reads . This is column of , with for : upper Hessenberg.
- By construction is orthogonal to and has norm 1.
- By induction, . The orthonormal vectors lie in , whose dimension is at most , so they are a basis.
- Multiply by . Since : .
- Ritz values. is compressed onto . Its eigenvalues (Ritz values) approximate eigenvalues of , the extreme ones first. For an eigenpair with , the residual is : a free error estimate.
- Breakdown means is invariant under : the Ritz values are exact eigenvalues ("lucky" breakdown).
- Cost. products with , about flops of orthogonalization, numbers of
memory. ARPACK (
eigs,eigsh) restarts to bound . - Lanczos. If is symmetric, is symmetric and Hessenberg, so it is tridiagonal: with diagonal and off-diagonal . The loop collapses to the three-term recurrence , with work per step beyond the product. In floating point the lose orthogonality as soon as a Ritz value converges (Paige), and copies ("ghosts") of converged eigenvalues appear. Full or selective reorthogonalization fixes this.
Move or press Play. Each column holds the Ritz values of a symmetric matrix after Lanczos steps; the ticks on the right are its eigenvalues. The isolated eigenvalues 2.0 and 1.5 are found first, then the edges of the dense block ; the interior never converges in 60 steps. Switch off reorthogonalization and go past : a stray Ritz value climbs up and becomes a second copy of 2.0 (a ghost).
Conjugate gradient #
Let be SPD, , error , residual , and (the -norm, or energy norm).
- Energy. . Minimizing is minimizing the -norm error, and .
- Definition. The CG iterate is .
- Optimality = orthogonal residual. is this minimizer exactly when for all , that is, .
- The algorithm finds with short recurrences and one product per step:
The residuals are mutually orthogonal and the directions are -conjugate ( for ). In an -orthogonal basis the minimization splits into one-dimensional problems, so adding a new direction never changes the old coefficients: progress is never undone. CG is Lanczos applied to .
- Why SPD. Positive definiteness makes a norm and strictly convex; symmetry gives the short recurrence.
CG as a polynomial problem. Every in has an error of the form , where has degree at most and (step 1 of the proof below). In the eigenvector basis, multiplies the component of along by . So CG is fast when some polynomial with is small at every eigenvalue of :
- eigenvalues spread over : must be small on the whole interval, and the best one can do depends on through ;
- eigenvalues in a few clusters: put one root of in each cluster;
- only distinct eigenvalues: put a root on each, and is exactly 0 on the spectrum.
Change the spectrum and move . The blue curve is the CG polynomial : it starts at and its roots (blue dots) are the Ritz values. CG makes small at the eigenvalues (the ticks). The orange scaled Chebyshev polynomial is the best one can do knowing only ; the dashed lines at give the bound. With 3 distinct values CG is exact after 3 steps; with outliers three roots go to the outliers first, and then CG converges as if were 2.
Theorem (CG convergence) #
Proof.
- and , so with . Then with : degree , . Every such arises from some .
- CG minimizes over this set, which gives the equality.
- Write in orthonormal eigenvectors of . Then .
- The last inequality: choose one good polynomial (the scaled Chebyshev polynomial) and bound its maximum on . Details in the folded proof.
Step 4: the Chebyshev polynomial bound
The Chebyshev polynomial has degree , satisfies on , and grows fastest outside among such polynomials. Map onto and normalize so that :
- At the argument is , so .
- For the argument lies in , so the numerator is at most 1 in absolute value, and .
- For , .
- For : , so .
- Steps 2–4 give .
Consequences:
- Iterations. About , so .
- Steepest descent (exact line search) only reaches : about iterations, . CG replaces by .
- Few distinct eigenvalues. If has distinct eigenvalues, vanishes on the spectrum, so CG is exact after at most steps (exact arithmetic). Clustered eigenvalues give fast convergence; needs about 6 steps.
- Preconditioning. With an SPD that is cheap to invert (Jacobi, incomplete Cholesky, multigrid), CG on the preconditioned system converges with instead.
is , with of size and full column rank. In exact arithmetic, at most how many CG steps solve ?
has rank 5, so has the eigenvalue 1 (multiplicity 995) and at most 5 other eigenvalues: at most 6 distinct values. The polynomial over these values has degree at most 6, , and is zero on the spectrum. The -step and statements are true bounds, but much weaker here.
Drag and raise . On the contours of , steepest descent zigzags: each step stops where its line touches a contour, so the next gradient is perpendicular to it. CG takes the same first step, then a direction that is -conjugate to it, and reaches after 2 steps (). The default start is the worst case for : steepest descent meets its bound .
Answers to section 1, question 1. CG: iterations (the bound; in practice often fewer). Steepest descent: .
An SPD system has . Using the standard bounds, about how many iterations do CG and steepest descent need to reduce the -norm error by ?
CG: . Steepest descent: . The ratio is about , and it grows with .
GMRES #
For any nonsingular , GMRES chooses with the smallest residual . Write with the Arnoldi basis (, ). Then , and since has orthonormal columns, : a small least-squares problem, updated by one Givens rotation per step.
- The residual norms never increase (the spaces are nested).
- No short recurrence: step costs and all vectors are stored. In practice one restarts every steps (GMRES()), which can stagnate.
- Symmetric indefinite systems use MINRES (the same minimization with a Lanczos short recurrence).
| method | matrix | minimizes over | recurrence | work per step |
|---|---|---|---|---|
| CG | SPD | short (Lanczos) | 1 product + | |
| MINRES | symmetric | short (Lanczos) | 1 product + | |
| GMRES | any nonsingular | full (Arnoldi) | 1 product + |
The GMRES bound and non-normal matrices
For diagonalizable , the same polynomial argument as for CG gives
The rate depends on where the eigenvalues lie in the complex plane and on the non-normality , not on alone. Eigenvalues in a disk that does not contain 0 give linear convergence (section 5 shows a disk of radius 0.5 around 1: the residual halves each step). For strongly non-normal matrices ( huge) the eigenvalues can be misleading, and GMRES can stagnate for many steps before it converges.
4. Worked example #
A. QR steps by hand. , eigenvalues 3 and 1.
Gram–Schmidt on the columns: , , . The remainder has norm , so :
Check: trace and determinant are unchanged. The diagonal moves toward . Further unshifted steps give off-diagonal magnitudes : the ratio approaches .
Shifted steps. For with the Rayleigh shift : with and , the QR factors of are and . The entry of is . When is small, the new is about : cubic. From (, ): . Three shifted steps reach this level; unshifted steps from would need 26. The exact second iterate is . (The Wilkinson shift of a matrix is an exact eigenvalue, so it deflates in one step.)
With the Rayleigh shift, the off-diagonal entry of this example goes , and the diagonal gap is now . What is the next value, roughly?
For small the new entry is about : cubic convergence, because the shift is Rayleigh quotient iteration on the last column. NumPy gives . Only the Wilkinson shift (an exact eigenvalue for a matrix) gives 0 in one step.
B. CG by hand. (SPD, ), , . The solution is , and .
Step 0.
- and .
- .
- .
- .
- . Check: .
- .
- .
Step 1.
- .
- Conjugacy check: .
- .
- .
- .
- .
What to notice:
- Step 0 is the best point on the line : . Its error is .
- After steps CG is exact, because .
- Steepest descent from the same start also has , but then with , and with : it zigzags and is never exact.
5. In code #
SciPy checks the worked example and shows the facts of this lesson:
import numpy as np
from scipy.linalg import hessenberg, schur, svd
# The worked example: one QR step is an orthogonal similarity
A = np.array([[2., 1.], [1., 2.]])
Q0 = np.array([[2., -1.], [1., 2.]]) / np.sqrt(5) # Gram-Schmidt Q of A
R0 = np.array([[5., 4.], [0., 3.]]) / np.sqrt(5)
A1 = R0 @ Q0
print(np.allclose(Q0 @ R0, A), A1.round(12).tolist()) # True [[2.8, 0.6], [0.6, 1.2]]
print(np.allclose(A1, Q0.T @ A @ Q0), np.linalg.eigvalsh(A1)) # True [1. 3.]
# Phase 1 of eig: Hessenberg form (symmetric input: tridiagonal form)
rng = np.random.default_rng(0)
M = rng.standard_normal((6, 6))
H, Qh = hessenberg(M, calc_q=True)
print(np.abs(np.tril(H, -2)).max(), np.allclose(Qh @ H @ Qh.T, M)) # 0.0 True
T = hessenberg(M + M.T)
print(np.abs(np.triu(T, 2)).max() < 1e-12) # True: tridiagonal
# The end point: real Schur form M = Z T Zᵀ, quasi-triangular (2x2 blocks = complex pairs)
Tm, Z = schur(M)
print(np.allclose(Z @ Tm @ Z.T, M), np.round(np.diag(Tm, -1), 3)) # True, nonzeros only in 2x2 blocks
# SVD: two LAPACK drivers agree; eig(BᵀB) loses the small singular value
Qa, _ = np.linalg.qr(rng.standard_normal((50, 4)))
Qb, _ = np.linalg.qr(rng.standard_normal((4, 4)))
B = Qa @ np.diag([1, 1e-3, 1e-6, 1e-10]) @ Qb.T
s_dd = svd(B, compute_uv=False, lapack_driver="gesdd") # bidiagonalize + divide and conquer
s_qr = svd(B, compute_uv=False, lapack_driver="gesvd") # bidiagonalize + implicit QR iteration
s_eig = np.sqrt(np.abs(np.linalg.eigvalsh(B.T @ B)))[::-1]
print(s_dd) # [1.e+00 1.e-03 1.e-06 1.e-10] (the last one to about 7 digits)
print(s_qr) # the same
print(s_eig) # last entry 1.0e-08: rounding noise, not 1e-10
Krylov methods, with only products :
import numpy as np
import scipy.sparse as sp
from scipy.sparse.linalg import cg, gmres, eigsh, LinearOperator
def poisson_2d(n): # 5-point Laplacian on an n x n grid, size n² x n²
T = sp.diags([-1.0, 2.0, -1.0], [-1, 0, 1], shape=(n, n))
I = sp.identity(n)
return (sp.kron(I, T) + sp.kron(T, I)).tocsr()
rng = np.random.default_rng(0)
# 1) CG iterations grow like sqrt(kappa): kappa = cot²(pi h / 2) with h = 1/(n+1)
for n in (16, 32, 64, 128):
A, b, it = poisson_2d(n), rng.standard_normal(n * n), [0]
x, info = cg(A, b, rtol=1e-8, callback=lambda xk: it.__setitem__(0, it[0] + 1))
kappa = 1 / np.tan(np.pi / (2 * (n + 1))) ** 2
print(f"size {n*n:6d} sqrt(kappa) {np.sqrt(kappa):5.1f} CG iterations {it[0]:4d}")
# size 256: 10.8, 52 · 1024: 21.0, 101 · 4096: 41.4, 198 · 16384: 82.1, 385 (about 4.8 sqrt(kappa))
# 2) Few distinct eigenvalues: I + (rank 5) has at most 6, so CG needs about 6 steps
N = 2000
U = rng.standard_normal((N, 5))
b, it = rng.standard_normal(N), [0]
x, info = cg(np.eye(N) + U @ U.T, b, rtol=1e-10, callback=lambda xk: it.__setitem__(0, it[0] + 1))
print("I + rank 5:", it[0], "iterations") # 6
# 3) Lanczos (ARPACK eigsh) with only products v -> Xᵀ(Xv): PCA without forming XᵀX
m, n = 20000, 1000
X = rng.standard_normal((m, n))
X += rng.standard_normal((m, 3)) @ np.diag([6.0, 4.0, 3.0]) @ np.linalg.qr(rng.standard_normal((n, 3)))[0].T
calls = [0]
def gram(v):
calls[0] += 1
return X.T @ (X @ v)
top = eigsh(LinearOperator((n, n), matvec=gram, dtype=float), k=3, which="LA", return_eigenvectors=False)
print(np.allclose(np.sort(top), np.linalg.eigvalsh(X.T @ X)[-3:]), calls[0], "products") # True 21 products
# 4) GMRES: residuals never increase; rate set by the eigenvalues (here a disk of radius 0.5 around 1)
n = 1000
A = np.eye(n) + 0.5 * rng.standard_normal((n, n)) / np.sqrt(n)
res = []
x, info = gmres(A, rng.standard_normal(n), rtol=1e-10, restart=200, maxiter=1,
callback=lambda r: res.append(r), callback_type="pr_norm")
print(len(res), "iterations", np.round(res[:4], 3), bool(np.all(np.diff(res) <= 0)))
# 33 iterations [0.447 0.226 0.109 0.055] True: each step about halves the residual
For the 2-D Poisson matrix grows like , so and the CG iteration count double when the grid spacing halves. This is why fluid and climate solvers precondition with multigrid, which makes the count almost independent of the grid.
6. Where it shows up #
- Hessian spectra in deep learning. Lanczos with Hessian-vector products (lesson 15) gives the top eigenvalues of a network Hessian without forming it. The largest one bounds stable learning rates ( for gradient descent on a quadratic).
- Gaussian processes. GPyTorch solves with preconditioned CG and estimates with Lanczos, using only kernel matrix-vector products.
- ML for science. Pressure-Poisson solves in incompressible flow (CG with multigrid);
implicit time steps of climate and ocean models (Jacobian-free Newton–Krylov: GMRES with
Jacobian-vector products only); inverse problems (LSQR, which is Golub–Kahan bidiagonalization
built from Krylov vectors); spectral clustering of a sensor graph and the leading EOFs of a huge
ensemble (
eigsh,svds).
7. Common mistakes #
- Mixing up the QR factorization and the QR algorithm. The algorithm repeats factorizations; one factorization gives no eigenvalues.
- Unshifted QR on a dense matrix. per step and linear convergence. Reduce to Hessenberg/tridiagonal form first, shift, and deflate.
- CG on a matrix that is not SPD. It can stall or diverge. Use GMRES (any matrix), MINRES (symmetric indefinite), or CG on the normal equations only if squaring is acceptable.
- The plain Krylov basis It is numerically rank deficient after a few steps; always orthonormalize (Arnoldi, Lanczos).
- Expecting exact arithmetic. CG does not stop exactly after steps, and plain Lanczos shows ghost eigenvalues. Stop on the residual (a small residual can hide a large error when is large, lesson 13).
8. Check yourself #
- Show that one shifted QR step , keeps the eigenvalues.
Answer
, so : an orthogonal similarity. - A symmetric matrix has eigenvalues 10, 9 and 1. In the unshifted QR algorithm, which
subdiagonal entry converges slowly, and about how many steps does it need to shrink by ?
Answer
Entry decays like : steps. Entry decays like : about 9 steps. A shift near 9 or 10 removes the problem. - Why is reduced to Hessenberg form before the QR iteration, and not to triangular form?
Answer
The one-time reduction costs , after which each QR step costs ( if tridiagonal) and keeps the form. Triangular form would reveal the eigenvalues, which no finite sequence of operations can do for . - Write the Arnoldi relation with the shapes of all matrices. What changes when is symmetric?
Answer
: is , is , is with orthonormal columns, is upper Hessenberg, and . For symmetric , is tridiagonal (Lanczos, three-term recurrence). - . Use the bounds to compare CG with steepest descent for a reduction
of the -norm error.
Answer
CG: iterations. Steepest descent: . A preconditioner that lowers helps both, CG through . - An SPD matrix of size 3000 has only the eigenvalues 1, 2 and 3. How many CG steps are needed
in exact arithmetic?
Answer
At most 3: has degree 3, , and is zero on the spectrum.
Inverse iteration with shift : which eigenvector does it find, and at what rate?
The eigenvector of , the eigenvalue closest to . The error shrinks by per step, where is the next closest eigenvalue.
How fast does Rayleigh quotient iteration converge for a symmetric matrix, and why?
Cubically. An eigenvector error gives an Rayleigh quotient, and inverse iteration with that shift multiplies the error by .
Why does one QR step keep the eigenvalues?
, so : an orthogonal similarity.
Why is reduced to Hessenberg form before the QR iteration?
The reduction costs once; QR steps keep the Hessenberg form and then cost only each ( if tridiagonal).
What is the Wilkinson shift?
The eigenvalue of the trailing block of that is closer to the corner entry . Unlike the Rayleigh shift, it never stalls on symmetric tridiagonal matrices.
Define the Krylov subspace .
. It needs only matrix-vector products.
State the Arnoldi relation.
, with orthonormal columns in and of size upper Hessenberg; .
What does the Arnoldi matrix become when is symmetric, and what is the method called?
Tridiagonal (), so a three-term recurrence is enough. This is Lanczos.
What does CG minimize, and what does GMRES minimize, over ?
CG minimizes the -norm error (SPD ). GMRES minimizes the residual (any nonsingular ).
Give the CG convergence bound with .
, so about iterations.
9. Interview angle #
- "How does
np.linalg.eigwork?" — Householder reduction to Hessenberg form, then the shifted (Francis) QR algorithm with deflation;eighreduces to tridiagonal form and uses divide and conquer;svdbidiagonalizes (Golub–Kahan) and uses divide and conquer (gesdd). - "Solve a sparse SPD system with unknowns." — CG with a preconditioner (multigrid, incomplete Cholesky): iterations of one sparse product each, memory. For a 2-D problem, a sparse Cholesky with a fill-reducing ordering is also good.
- "Top eigenvector of a huge matrix or of a Hessian?" — Lanczos (or power iteration) with matrix-vector (Hessian-vector) products only.
- "CG versus gradient descent?" — on a quadratic, CG picks the optimal polynomial: instead of . Momentum methods (heavy ball, Nesterov) also reach a rate.
10. Practice #
The notebook for this lesson runs in Colab. It has five exercises, each with a check cell and a folded solution:
- Write inverse iteration with one LU factorization, and check its rate .
- Write Rayleigh quotient iteration and watch the number of correct digits triple.
- Write the unshifted QR algorithm, record the subdiagonal entries, and compare their decay with .
- Write Lanczos with full reorthogonalization, check , and compare the Ritz values with the extreme eigenvalues of a 1-D Laplacian.
- Write conjugate gradients, solve a 1-D Poisson problem, and compare its iteration count with steepest descent.
11. Watch and read #
- Trefethen and Bau, Numerical Linear Algebra (SIAM 1997): Lectures 25–31 (eigenvalue algorithms, Hessenberg reduction, Rayleigh quotient and inverse iteration, QR without and with shifts, computing the SVD) and 32–38, 40 (Arnoldi, GMRES, Lanczos, CG, preconditioning).
- Driscoll and Braun, Fundamentals of Numerical Computation, free online, chapter 8: §8.2 power iteration, §8.3 inverse iteration, §8.4 Krylov subspaces, §8.5 GMRES, §8.6 MINRES and CG and §8.8 preconditioning.
- Jonathan Shewchuk, "An Introduction to the Conjugate Gradient Method Without the Agonizing Pain" (1994): §6 (steepest descent convergence), §7–8 (conjugate directions, CG), §9 (CG convergence and Chebyshev polynomials).
- Cleve Moler, "The QR Algorithm Computes Eigenvalues and Singular Values" (2019).
Runs in your browser with nothing to install. The notebook repeats the key demos and has exercises with checks; solutions are inside, folded.
No Google account needed: Python runs inside your browser. The first start downloads about 40 MB; your changes are saved in this browser only.