16 / 16 · Numerical Computation
Iterative methods: power iteration and conjugate gradient
When a matrix is too large to factorize, multiply by it instead: the power method for the top eigenvector, conjugate gradient for a positive definite system, Krylov subspaces, the square-root rate and preconditioning.
Conditioning and numerical stability · Symmetric matrices and quadratic forms · Unconstrained optimization
On this page 9
Take a linear system with a million unknowns: the values of a field on a grid, the weights of a large regression, the coefficients of a kernel model. Every method in the course so far would factorize the matrix. For that is out of reach:
| Quantity | Dense LU | One sparse product |
|---|---|---|
| storage | doubles, 8 TB | 5 nonzeros per row, 64 MB |
| arithmetic | flops | flops |
The LU count is derived in the linear systems note: step updates an block, and the sum of squares gives multiply–adds (Boyd and Vandenberghe, 2004, Appendix C.3). At flops per second the factorization would take most of a day, on a machine with 8 TB of memory. The product with a sparse matrix takes milliseconds. Many matrices of machine learning are not even stored: a Hessian is available only through Hessian–vector products, a kernel matrix through a routine that multiplies it by a vector.
What can be computed from products alone? More than one might expect: the largest eigenvalue, by the power method, and the solution of for a symmetric positive definite , by conjugate gradient. Both build their answers from the same vectors , and both are slowed down by the same thing, a spectrum that is hard to separate.
The power method#
Multiply any vector by again and again, and its direction turns towards the eigenvector of the largest eigenvalue, as the eigenvalue note showed for matrix powers. The power method turns this into an algorithm. Start from a random and repeat
The normalization only keeps the numbers from overflowing; is the Rayleigh quotient, the estimate of the eigenvalue.
Why it works: let be symmetric with orthonormal eigenvectors and eigenvalues ordered by size, . Expand the start as with . Each multiplication scales the -th component by :
Every term of the sum shrinks at least as fast as . The normalized is divided by its length, so it has the same angle to . The are orthonormal, so the tangent of that angle is the length of the part orthogonal to over the part along it:
The distance from falls by the factor per step: the convergence rate of the power method.
The eigenvalue estimate converges twice as fast. Write a unit vector as , with a unit vector orthogonal to . Then , and
Here . An error in the direction costs only in the eigenvalue, because the Rayleigh quotient is stationary at an eigenvector, and is at most . With from above, the error of for a symmetric matrix falls like .
Example. For , with eigenvalues 6 and 1, start from :
| Step | 0 | 1 | 2 | 3 |
|---|---|---|---|---|
| 5 | 5.96552 | 5.99904 | 5.99997 | |
| 1 |
The error falls by about per step.
Each step costs one product with and two vectors of memory, which is why the method and its relatives run wherever a matrix is too large to decompose. Spectral normalization of a GAN estimates the largest singular value of each weight matrix with one power step per training step, warm-started from the previous step’s vector. PageRank is the dominant eigenvector of a transition matrix with one row per web page. The step size of gradient descent needs , the largest eigenvalue of a Hessian, which the power method estimates from Hessian–vector products.
Where it breaks: a small gap#
The rate is close to 1 when the top two eigenvalues are close, and then the method crawls. A matrix met everywhere in numerical work shows it. The grid Laplacian on an grid has the row
with neighbours outside the grid set to zero. It has unknowns, at most five nonzeros per row, and eigenvalues known in closed form,
between and . Divided by , with grid spacing , each row is the five-point difference approximation of , the operator behind diffusion and smoothing on images and meshes.
Derivation: the eigenvalues of the grid Laplacian
Start with one dimension: the matrix with 2 on the diagonal and beside it. Try the vector with . The identity gives, for each row ,
The first and last rows lack a neighbour, but the missing terms are and , so the formula holds there too. The grid Laplacian is , one along each grid direction, and with . The products give all eigenvalues. Finally gives the smallest one.
For the ratio is . Each step removes 0.036% of the unwanted components, and the power method needs 17,142 steps to get to six digits. SciPy’s eigsh, which wraps the implicitly restarted Lanczos method of the ARPACK library, gets it to full precision with 511 products. The difference is in how the products are used. The power method keeps only the latest vector , while Lanczos finds the best estimate in the span of all of them, the Krylov subspace of the section below.
Two other remedies change the matrix instead. Inverse iteration with a shift applies the power method to . Its eigenvalues are , so the largest belongs to the eigenvalue of nearest to , and the rate of the power method becomes , where here is the eigenvalue nearest to and the next-nearest. A shift close to makes it tiny, at the price of a linear solve per step. Rayleigh quotient iteration updates the shift to the current at every step and converges cubically for symmetric matrices (Rakhuba, 2025, lecture 17). For several eigenvectors at once, subspace iteration multiplies a block of vectors and re-orthonormalizes it by QR after each step; its rate is .
Solving Ax = b by minimizing a quadratic#
For a symmetric positive definite , the system is an optimization problem in disguise. Define
Its gradient is , so its only stationary point, and its minimum, is the solution . The negative gradient is the residual . The distance to the minimum is measured best in the energy norm , because the excess of is exactly half its square:
where the first line substitutes .
The unconstrained optimization note has a method for this: gradient descent. On a quadratic the best step along the residual can be computed exactly. Setting the derivative of to zero,
gives and steepest descent. The same equation says that the new residual is orthogonal to the old one. With the condition number of , the error of steepest descent in the energy norm shrinks per step by at least the factor
derived below as the one-step case of the CG bound (Shewchuk, 1994, §6.2). Reducing the error by a factor takes about steps, because for small , here . Because each new gradient is perpendicular to the old one, on an elongated bowl the iterates zigzag across the valley, undoing part of the progress they made along it.
Even on a system the method never finishes. For the matrix of the example above and , with solution , the relative error in the energy norm after steps 1 to 6 is
roughly halving at every step, forever.
Conjugate directions#
In a round bowl, , the zigzag disappears. Minimizing along each coordinate axis in turn finds the minimum in steps, because a step along one axis does not spoil the minimum already found along the others. An elongated bowl is a round one in stretched coordinates: with the quadratic becomes (Merkulov, 2024, lecture 12). A direction in is in , and . So directions that are orthogonal in are, back in , conjugate or -orthogonal:
Exact line searches along conjugate directions reach in steps. To see why, expand the initial error in the directions, . This is possible because nonzero conjugate directions are linearly independent: multiplying by leaves , and , so every . Multiplying the expansion by kills every term but one, and :
The line search along from chooses , by the same derivative as for steepest descent with in place of . The residual differs from only by vectors that are orthogonal to , so . Each line search therefore removes exactly one component of the error and leaves the others alone. After steps none are left (Shewchuk, 1994, section 7).
The difficulty is to find conjugate directions cheaply. The eigenvectors of are conjugate, but computing them is harder than solving the system. Gram–Schmidt in the inner product makes any basis conjugate, but each new direction must be orthogonalized against all previous ones, at a cost that grows with every step.
Conjugate gradient#
The conjugate gradient method (CG) of Hestenes and Stiefel (1952) makes conjugate directions out of the residuals, and, as shown below, the residuals need almost no orthogonalization. Start with , , , and repeat
The first line is the exact line search along ; the derivation below shows why its numerator can be . The next two move the point and update the residual with the product , the only product with in the step. The last two make the new direction from the new residual, with chosen so that is conjugate to .
A step costs one product with , two inner products and three vector updates, and the method stores four vectors. Conjugacy to is all that the formula enforces, yet the new direction comes out conjugate to every earlier one as well. As long as no residual is zero, three facts hold at every step (Shewchuk, 1994, section 8; Rakhuba, 2025, lecture 15):
- The residuals are mutually orthogonal, and is orthogonal to .
- The residuals and the directions both span the space of .
- The directions are conjugate: for .
The heart of the induction is one line. For , the update gives , a vector in the span of , to which is orthogonal by fact 1. So , and Gram–Schmidt of against has nothing to subtract: only the last direction needs a correction. The name is a misnomer: it is the directions that are conjugate, and they are built from gradients.
Derivation: the induction behind CG
Assume the three facts up to step ; at they say only that spans the space of . Write the line-search step as .
Residual against directions. From , the choice of gives . For , by facts 1 and 3.
Residuals against residuals. Each with lies in the span of by fact 2, so .
The two formulas of the algorithm. Since and , we have , so . Gram–Schmidt in the -inner product sets . Substitute and , and use :
Conjugacy. by the choice of . For , ; the first term is zero by the one-line argument above and the second by fact 3.
Spans. and lie in the space of , because does. The residuals are nonzero and mutually orthogonal, hence independent, so they span that space, whose dimension is at most . The directions are nonzero, since , and conjugate, hence independent as well.
Example. The same system, and , by hand:
| Step | new | new | new | ||
|---|---|---|---|---|---|
| 0 | |||||
| 1 |
The first step is a step of steepest descent, with . The second direction differs from the residual , and it is conjugate to the first: . Two steps give the exact solution, where steepest descent was still 2% away after six.
Krylov subspaces#
Every vector CG computes is a combination of . The span of the first of them is the Krylov subspace
Its vectors are cheap, one product with each. CG picks the best point of the growing space: minimizes the energy-norm error over all of , equivalently minimizes there (Rakhuba, 2025, lecture 15). The power method computes the same vectors and keeps only the last one.
Derivation: CG is optimal over the Krylov space
The proof is Pythagoras in the energy norm. The iterate lies in , and its error has , which is orthogonal to and hence to all of . For any put :
which is smallest at , that is at .
The best point can be described by polynomials. A point of is for a polynomial of degree below , so its error is with : a polynomial of degree with . Expanding in orthonormal eigenvectors of , as for the power method, gives and
This turns the minimization into a bound on the spectrum, with for the start :
CG converges as fast as a polynomial with can be made small at all the eigenvalues at once. The spread of the eigenvalues matters as much as their range:
- With distinct eigenvalues, the polynomial of degree vanishes at all of them, so CG is exact after steps, in exact arithmetic.
- Eigenvalues in a tight cluster are almost one eigenvalue. On a cluster of width around , the single factor is at most .
- An isolated outlier costs about one step. The factor vanishes at it and stays below 1 in absolute value on , so multiplying it into a polynomial that is small on the other eigenvalues keeps that polynomial small there.
Two spectra with the same condition number show the difference. A diagonal matrix with 1,000 eigenvalues spread evenly over needs 176 CG steps to bring the relative residual to . One with 995 eigenvalues in and five outliers up to 1,000 needs 24.
In floating point the vectors make a terrible basis. They all turn towards the top eigenvector, as in the power method, so their matrix is badly conditioned; Strang (2006) works out a example in which it already has condition number about 1,000. Krylov methods therefore orthogonalize as they go. For symmetric the orthogonalization needs only the two previous vectors, a three-term recurrence called the Lanczos process, and CG is one way of organizing it. The reason: with the orthonormal basis built so far, the matrix of coefficients has zeros below its first subdiagonal, because times the -th basis vector lies in the span of the first ; for symmetric it is also symmetric, hence tridiagonal (Strang, 2006). The restriction of to the orthonormal basis is a small tridiagonal matrix whose eigenvalues approximate the extreme eigenvalues of (Rakhuba, 2025, lectures 17–18), which is how eigsh found the top eigenvalue above.
For a nonsymmetric , Arnoldi’s process orthogonalizes against all previous vectors, and GMRES picks the point of with the smallest residual; for a symmetric indefinite the short-recurrence version is MINRES (Rakhuba, 2025, lecture 16).
The square root of the condition number#
Without knowing the eigenvalues, only their range , we can put a specific polynomial into the bound: any with gives an upper bound. The right choice is a shifted and scaled Chebyshev polynomial, which is in fact the polynomial of degree that stays smallest on the interval among the polynomials equal to 1 at zero (Shewchuk, 1994, appendix C3). Its size on the interval gives (Shewchuk, section 9.2; Merkulov, 2024, lecture 12, Theorem 2)
Derivation: the square-root bound
The Chebyshev polynomials are , and , so has degree . Two facts follow from the recurrence. On , write : then , because is the same recurrence with the same first two values, so there. For , write with : then , by the same recurrence for , which also starts from and , so .
Map the interval onto by and take , so that . On the interval , with . Since ,
and , the bound above. For the value is exact, , so one step from any starting point reduces the energy-norm error by at least . A step of steepest descent is such a step: it minimizes along the current residual, the one-dimensional Krylov space at the current point. This proves the steepest-descent factor quoted earlier.
Compare the steepest-descent factor : CG has the same expression with in place of . To reduce the error by a factor , using with and :
For and six digits that is the difference between about 69,000 and 725 steps.
The grid Laplacian with has . With all ones, reducing the energy-norm error a millionfold takes:
| Method | Bound | Steps taken |
|---|---|---|
| steepest descent | 28,554 | 28,369 |
| conjugate gradient | 466 | 144 |
Steepest descent follows its bound almost exactly. CG beats its own bound threefold. The bound replaced each in by the worst one, and here many are zero. The eigenvectors are products of the sine vectors , and for even such a vector is antisymmetric about the middle of the grid, so its sum, the component of along it, is zero. Only the quarter of the eigenvectors with and both odd take part.
Momentum gives gradient descent the same rate on a quadratic, but only with step and momentum tuned from and . CG needs neither. Started from 0, gradient descent with or without momentum adds at each step multiples of the current residual and of the previous step, so its -th iterate lies in ; CG’s minimization over that space makes it at least as good in the energy norm.
The makes CG practical at the size of the opening example. The Laplacian with has unknowns and . CG brings the relative residual to in 1,853 steps, about flops and seconds of time, with 64 MB for the matrix and 32 MB for the four vectors.
Where it breaks: rounding and ill-conditioning#
Finite termination is a property of exact arithmetic. In floating point the residuals slowly lose their orthogonality and the directions their conjugacy, so information that CG had already used comes back. Ridge regression with 200 features whose scales range from 1 to 1,000 leads to the system with . CG needs 2,904 steps on this system, almost fifteen times the dimension. The method still converges. This behaviour made numerical analysts set CG aside in the 1960s, and it returned in the 1970s as an iterative method, judged by how fast its residual falls (Shewchuk, 1994, section 9).
The stopping test has the same subtlety. CG never sees the error, only the residual, and the usual test is . A small residual guarantees a small error only up to the factor : the relative error is at most times the relative residual, by the bound of the conditioning note. The recursively updated also drifts from the true , since rounding errors in the update are never corrected against , and long runs recompute it from time to time (Shewchuk, sections 4 and 9).
Preconditioning#
If sets the speed, change the system so that becomes small. A preconditioner is a symmetric positive definite whose systems are cheap to solve. CG is then applied to , written symmetrically through a factor as with . The factor never appears in the algorithm: each step needs one solve with (Shewchuk, 1994, section 12; Rakhuba, 2025, lecture 17). The rate is set by the eigenvalues of , because has the same ones: is a similar matrix.
The simplest choice, or Jacobi, rescales the variables; for the ridge system above it lowers from to 3.55 and the step count from 2,904 to 20. It is the matrix version of scaling the features before gradient descent. Incomplete Cholesky factors, which drop the fill-in of the exact factorization, are a stronger choice (Shewchuk, section 12).
CG also runs inside other methods. Newton’s method needs the step , and for a network with millions of weights the Hessian cannot be stored. Hessian-free optimization solves that system approximately by a few CG steps that need only products of a vector with or with its Gauss–Newton approximation, which automatic differentiation computes at the cost of a few gradients (Martens, 2010). SciPy’s Newton-CG method implements the same idea.
Code#
The costs of the opening, the power method on the example and on the grid Laplacian against eigsh, CG written out on the system, steepest descent against CG with their bounds, two spectra with the same , Jacobi preconditioning of a ridge system, and CG with a million unknowns. It runs in about 15 seconds, most of them in the last part; exact digits can differ across platforms and library versions, and the step count of eigsh with the ARPACK version.
import numpy as np
import scipy.sparse as sp
from scipy.sparse.linalg import eigsh, spsolve, LinearOperator
# the 5-point Laplacian on an N x N grid: n = N^2 unknowns, at most 5 nonzeros per row
def laplacian_2d(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()
# 1. what n = 10^6 costs: dense LU against one sparse matrix-vector product
n = 10**6
print(f'{2 / 3 * n**3:.1e} flops, {8 * n**2 / 1e12:.0f} TB dense; {2 * 5 * n:.0e} flops per sparse product')
# 6.7e+17 flops, 8 TB dense; 1e+07 flops per sparse product
# 2. the power method on a 2 x 2 matrix with eigenvalues 6 and 1
A = np.array([[5.0, 2.0], [2.0, 2.0]])
x = np.array([1.0, 0.0])
quotients = []
for k in range(4):
quotients.append(x @ A @ x / (x @ x)) # Rayleigh quotient of the current vector
x = A @ x / np.linalg.norm(A @ x)
print(np.round(quotients, 5), [f'{6 - q:.1e}' for q in quotients])
# [5. 5.96552 5.99904 5.99997] ['1.0e+00', '3.4e-02', '9.6e-04', '2.7e-05']
# 3. the power method where the gap is small: the Laplacian with N = 100 (n = 10,000)
N = 100
L = laplacian_2d(N)
lam1 = 4 + 4 * np.cos(np.pi / (N + 1)) # the eigenvalues are known in closed form
lam2 = 4 + 2 * np.cos(np.pi / (N + 1)) + 2 * np.cos(2 * np.pi / (N + 1))
rng = np.random.default_rng(0)
x = rng.normal(size=N * N)
for k in range(1, 100_001):
y = L @ x
q = x @ y / (x @ x)
x = y / np.linalg.norm(y)
if (lam1 - q) / lam1 < 1e-6:
break
count = [0]
def matvec(v):
count[0] += 1
return L @ v
top = eigsh(LinearOperator(L.shape, matvec=matvec, dtype=float), k=1, which='LA', tol=1e-10,
v0=np.random.default_rng(0).normal(size=N * N))[0][0]
print(round(lam2 / lam1, 5), k, count[0], abs(top - lam1) < 1e-12)
# 0.99964 17142 511 True
# 4. conjugate gradient, written out; keep=True also returns the iterates
def conjugate_gradient(A, b, tol=1e-10, maxiter=100_000, Minv=None, keep=False):
x = np.zeros_like(b)
r = b.copy()
z = r if Minv is None else Minv * r # Minv: a diagonal preconditioner, or none
d = z.copy()
rz = r @ z
xs = [x.copy()] if keep else None
for k in range(1, maxiter + 1):
Ad = A @ d # the only product with A in the step
alpha = rz / (d @ Ad)
x = x + alpha * d
r = r - alpha * Ad
if keep:
xs.append(x.copy())
if np.linalg.norm(r) <= tol * np.linalg.norm(b):
break
z = r if Minv is None else Minv * r
rz, rz_old = r @ z, rz
d = z + (rz / rz_old) * d
return x, k, xs
def steepest_descent(A, b, x_star, tol, maxiter):
x, r = np.zeros_like(b), b.copy()
e0 = np.sqrt(x_star @ (A @ x_star))
errors = []
for k in range(1, maxiter + 1):
Ar = A @ r
x = x + (r @ r) / (r @ Ar) * r # exact line search along the residual
r = r - (r @ r) / (r @ Ar) * Ar
e = x - x_star
errors.append(np.sqrt(e @ (A @ e)) / e0)
if errors[-1] <= tol:
break
return k, errors
b = np.array([1.0, 1.0])
x, k, xs = conjugate_gradient(A, b, keep=True)
print(k, np.round(xs[1], 4), np.round(xs[2], 4))
print(np.round(steepest_descent(A, b, np.linalg.solve(A, b), 0, 6)[1], 3))
# 2 [0.1818 0.1818] [0. 0.5]
# [0.522 0.273 0.142 0.074 0.039 0.02 ]
# 5. steepest descent against CG on the Laplacian, b = all ones, error in the A-norm reduced 10^6-fold
b = np.ones(N * N)
x_star = spsolve(L.tocsc(), b)
kappa = lam1 / (4 - 4 * np.cos(np.pi / (N + 1)))
k_sd, _ = steepest_descent(L, b, x_star, 1e-6, 100_000)
_, _, xs = conjugate_gradient(L, b, tol=1e-12, keep=True)
e0 = np.sqrt(x_star @ (L @ x_star))
k_cg = next(k for k, x in enumerate(xs) if np.sqrt((x - x_star) @ (L @ (x - x_star))) <= 1e-6 * e0)
bound_sd = np.log(1e-6) / np.log((kappa - 1) / (kappa + 1))
bound_cg = np.log(1e-6 / 2) / np.log((np.sqrt(kappa) - 1) / (np.sqrt(kappa) + 1))
print(round(kappa), k_sd, round(bound_sd), k_cg, round(bound_cg))
print([round(c * np.log(f / 1e-6)) for c, f in ((1e4 / 2, 1), (1e2 / 2, 2))]) # kappa = 10^4: SD and CG estimates
# 4134 28369 28554 144 466
# [69078, 725]
# 6. the same condition number, two spectra: 1,000 eigenvalues spread over [1, 1000],
# or 995 of them in [1, 2] and five outliers up to 1000
spread = np.linspace(1, 1000, 1000)
clustered = np.concatenate([np.linspace(1, 2, 995), [100, 200, 400, 700, 1000]])
for lam in (spread, clustered):
print(lam.max() / lam.min(), conjugate_gradient(sp.diags(lam).tocsr(), np.ones(1000), tol=1e-8)[1])
# 1000.0 176
# 1000.0 24
# 7. preconditioning: ridge regression with features on scales from 1 to 1000
rng = np.random.default_rng(0)
X = rng.normal(size=(2000, 200)) * np.logspace(0, 3, 200)
y = X @ (rng.normal(size=200) / np.logspace(0, 3, 200)) + 0.1 * rng.normal(size=2000)
H, g = X.T @ X + np.eye(200), X.T @ y # (X^T X + I) w = X^T y
Minv = 1 / np.diag(H) # Jacobi: divide by the diagonal
ev = np.linalg.eigvalsh(H)
evp = np.linalg.eigvalsh(np.sqrt(Minv)[:, None] * H * np.sqrt(Minv)[None, :])
w_plain, k_plain, _ = conjugate_gradient(H, g)
w_jac, k_jac, _ = conjugate_gradient(H, g, Minv=Minv)
print(f'{ev[-1] / ev[0]:.1e} {evp[-1] / evp[0]:.2f}', k_plain, k_jac, np.allclose(w_jac, np.linalg.solve(H, g)))
# 1.1e+06 3.55 2904 20 True
# 8. n = 10^6: the Laplacian with N = 1000, stored in about 64 MB, solved by CG to a relative residual of 1e-8
L = laplacian_2d(1000)
b = np.ones(L.shape[0])
x, k, _ = conjugate_gradient(L, b, tol=1e-8, maxiter=10_000)
mem = (L.data.nbytes + L.indices.nbytes + L.indptr.nbytes) / 1e6
kappa = (4 + 4 * np.cos(np.pi / 1001)) / (4 - 4 * np.cos(np.pi / 1001))
flops = k * (2 * L.nnz + 10 * L.shape[0]) # per step: one product, two inner products, three updates
print(L.shape[0], L.nnz, round(mem), f'{kappa:.1e}', k, f'{flops:.1e}', f'{np.linalg.norm(b - L @ x) / np.linalg.norm(b):.1e}')
# 1000000 4996000 64 4.1e+05 1853 3.7e+10 9.9e-09
The course in one paragraph#
Machine learning is written in linear algebra, differentiated with calculus, trained by optimization and run in floating point; the course built each layer on the one before.
In linear algebra, data are vectors and models are linear maps between them (vectors and linear maps). Solving a system is elimination, the factorization (linear systems), and least squares is a projection (orthogonality). Eigenvalues describe repeated application (eigenvalues), symmetric matrices give the axes of quadratic forms, covariances and Hessians (symmetric matrices), and the SVD gives rank, low-rank approximation and PCA for every matrix (SVD).
In calculus, derivatives are best linear approximations (derivatives). In many variables they become gradients, Jacobians and Hessians chained by matrix products (gradients), written compactly for vector and matrix expressions (matrix calculus); the Jacobian determinant changes variables in integrals (multiple integrals).
In optimization, convexity turns a zero gradient into a certificate of a global minimum (convexity). Gradient descent needs about steps, and Newton’s method removes near the minimum (unconstrained optimization). Constraints are balanced by multipliers in the KKT conditions (KKT), whose dual gives lower bounds and the SVM’s form (duality).
In numerical computation, the condition number that set the speed of gradient descent also sets how many digits a computer can trust (conditioning). When a matrix is too large to factorize, products with it are enough: the power method finds its top eigenvector, and conjugate gradient solves a positive definite system in about steps.
Next#
The course ends here. The Probability course supplies the other half of the language of machine learning: random variables, expectations and the Gaussian, whose covariance matrices are the symmetric positive definite matrices of this course. The Machine Learning course builds on both, starting from data, losses and least squares. The Bayesian Methods course uses the linear algebra most heavily: its Gaussian processes solve kernel systems whose factorization is the wall this note started from.
References#
- M. R. Hestenes, E. Stiefel. Methods of conjugate gradients for solving linear systems. Journal of Research of the National Bureau of Standards, 49(6), 409–436, 1952.
- J. R. Shewchuk. An Introduction to the Conjugate Gradient Method Without the Agonizing Pain. Technical report CMU-CS-94-125, Carnegie Mellon University, 1994. Sections 4–6 (steepest descent and its convergence), 7 (conjugate directions), 8 (CG), 9 (convergence, Chebyshev polynomials, loss of conjugacy), 12 (preconditioning), 13 (CG on the normal equations).
- M. Rakhuba. Основы матричных вычислений (Foundations of matrix computations), lecture course, HSE University, Faculty of Computer Science, 2025/26. Course page; lecture 15 (Krylov subspaces, CG as minimization over them), lecture 16 (convergence of CG and its square-root bound, GMRES, MINRES), lecture 17 (preconditioning, the power method, inverse iteration with a shift, Rayleigh quotient iteration and its cubic rate for symmetric matrices, subspace iteration, the Rayleigh–Ritz method), lecture 18 (Arnoldi and Lanczos).
- D. Merkulov. Optimization for ML, HSE University, 2024. Course site; lecture 12 (the conjugate gradient method: conjugate directions, convergence, Theorems 1 and 2, non-linear CG).
- G. Strang. Matrix Methods in Data Analysis, Signal Processing, and Machine Learning (MIT 18.065), lecture 12 (computing eigenvalues; Krylov spaces), MIT OpenCourseWare, 2018; and Krylov subspaces and conjugate gradients, notes for MIT 18.086, 2006 (the conditioning of the Krylov basis; Arnoldi becomes Lanczos for symmetric A).
- S. Boyd, L. Vandenberghe. Convex Optimization. Cambridge University Press, 2004. Appendix C (numerical linear algebra: flop counts, C.3 LU and Cholesky factorization, sparse matrices).
- J. Martens. Deep learning via Hessian-free optimization. ICML, 2010.