M2 · Conjugate gradient and structured quadratics, from zero
Lectures 11–13 (17–24 Sep) · MT2 material · about 2.5 hours with practice · Goal: run CG by hand on a small quadratic, and answer "in how many iterations does CG converge?" for matrices like $\alpha I+uu^\top+2vv^\top$, with reasons.
Same as M1: a story, each section using only what came before; Check boxes as you go; the Summary card at the end is for revision. This page builds on M1 (exact line search, eigenvalues of a quadratic, zig-zag).
Why this module is second: CG appeared in 2016 (Q2, Q3, Q4), 2020 (P1 Q4), 2025 (Q3, which was 2016 Q4 again), as T/F items in 2024 and 2025, and as 4 of the 6 MT2 questions this year.
Notation (his, from MT2):
- $d$ = dimension ($x\in\mathbb R^d$). $S^d$ = symmetric $d\times d$ matrices.
- $f(x)=\frac12x^\top Qx-h^\top x+c$ with $Q\in S^d$, $Q\succ0$ (symmetric, positive definite). Minimiser $x^*=Q^{-1}h$. $\kappa=\lambda_{\max}/\lambda_{\min}$ (condition number, as in M1).
- $g^{(k)}=\nabla f(x^{(k)})=Qx^{(k)}-h$ = gradient at step $k$. (In a linear system it is minus the "residual" $h-Qx$.)
- $u^{(k)}$ = search direction; $\alpha_k$ = step length; $\beta_k$ = the mixing number in CG.
- $E(x)=\frac12(x-x^*)^\top Q(x-x^*)=f(x)-f^*$: the error measure he uses (same as $\Delta$ in M1).
- $(\lambda_i,v_i)$ = eigenvalue and unit eigenvector of $Q$: $Qv_i=\lambda_iv_i$. Because $Q$ is symmetric, the $v_i$ can be chosen orthonormal.
- The start error $x^{(0)}-x^*=\sum_ic_iv_i$ touches eigenvalue $\lambda_i$ if $c_i\ne0$ (it has a component along that eigenvector).
- In section E, I write structured matrices as $\sigma I+aa^\top+2bb^\top$ so letters don't clash; his papers write $\alpha I+uu^\top+2vv^\top$ (there $\alpha$ is a number in the matrix, not a step length).
0. Why CG exists
In M1, steepest descent on a quadratic zig-zags: each exact line search fixes the current direction, but the next step partly undoes the progress made along earlier directions. With condition number $\kappa$ it needs a number of steps proportional to $\kappa$ for each extra digit of accuracy.
The fix: choose directions so that minimising along a new direction never spoils what was achieved along the old ones. Then each line search finishes one "coordinate" for good, and a $d$-dimensional quadratic is solved in at most $d$ steps. Such directions are called $Q$-conjugate. Conjugate gradient (CG) is the clever way of producing them cheaply, one at a time, from gradients.
CG minimises a quadratic in at most as many steps as the number of different eigenvalues that the starting error actually touches, and the exam is mostly about counting those.
Roadmap: A defines conjugacy. B shows why conjugate directions finish in $d$ steps. C builds CG and runs it by hand. D counts the steps (polynomial view). E applies the count to structured matrices. F uses CG for linear systems. G is the exam recipe.
A. Conjugate directions
In plain words: two directions are $Q$-conjugate if they are perpendicular after you measure angles the way $Q$ does. If you stretch space so the elliptical level sets of $f$ become circles, conjugate directions become ordinary perpendicular directions.
Nonzero vectors $u_1,\dots,u_m$ are $Q$-conjugate if $\;u_i^\top Qu_j=0\;$ for all $i\neq j$.
With $Q=I$ this is just "orthogonal".
$Q=\mathrm{diag}(1,4)$, $u=(1,1)$. Find $v$ conjugate to $u$: $u^\top Qv=v_1+4v_2=0$, e.g. $v=(4,-1)$. They are conjugate, but not orthogonal ($u^\top v=3$).
Three facts that are T/F favourites:
- Conjugate ⇒ linearly independent, if $Q\succ0$. Suppose $\sum_jc_ju_j=0$. Multiply by $u_i^\top Q$: all cross terms vanish, leaving $c_i\,u_i^\top Qu_i=0$. Since $Q\succ0$ and $u_i\ne0$, $u_i^\top Qu_i>0$, so $c_i=0$. Hence a matrix whose columns are conjugate directions has full column rank (MT2 T/F (b): True), and there are at most $d$ of them.
- If $Q$ is not positive definite this can fail (2016 Q2). Example: $Q=\mathrm{diag}(1,0)$, $a_1=e_2$, $a_2=2e_2$: $a_1^\top Qa_2=0$, yet $a_2=2a_1$. The proof breaks because $a_i^\top Qa_i$ can be $0$.
- Conjugate directions are not unique (MT2 T/F (a): False). Any eigenvector basis of $Q$ works, and so does conjugating any independent set (next point).
Making conjugate directions from any independent vectors (MT2 Q3(b)). This is Gram–Schmidt with the $Q$-inner product: $u_1=v_1$ and
$$u_i=v_i-\sum_{j<i}A_{ij}u_j,\qquad A_{ij}=\frac{v_i^\top Qu_j}{u_j^\top Qu_j}.$$Why: take $u_l^\top Q$ of both sides for some $l<i$; the earlier $u_j$ are already conjugate, so only $j=l$ survives: $u_l^\top Qu_i=v_i^\top Qu_l-A_{il}u_l^\top Qu_l$, which is $0$ for that $A_{il}$.
Show answer
$u_1=(1,0)$. $A_{21}=\frac{v_2^\top Qu_1}{u_1^\top Qu_1}=\frac12$. $u_2=(0,1)-\frac12(1,0)=(-\frac12,1)$. Check: $u_1^\top Qu_2=(2,1)\cdot(-\frac12,1)=0$ ✓.
B. Why conjugate directions finish in $d$ steps
Idea: write the unknown point in "conjugate coordinates". Then $f$ splits into separate one-variable parabolas, one per direction, and each can be minimised on its own.
- Take any start point $a$ (later: $a=x^{(0)}$) and conjugate directions $u_1,\dots,u_m$ (columns of a matrix $U$). Points of the form $x=a+Uy=a+\sum_iy_iu_i$.
- Expand: $f(a+Uy)=f(a)+\nabla f(a)^\top Uy+\frac12y^\top U^\top QUy$. Conjugacy makes $U^\top QU$ diagonal (off-diagonal entries are $u_i^\top Qu_j=0$). So $$f(a+Uy)=f(a)+\sum_i\Big(y_i\,\nabla f(a)^\top u_i+\tfrac12y_i^2\,u_i^\top Qu_i\Big):$$ a sum of separate parabolas, one in each $y_i$.
- Minimise each: $\boxed{\,y_i=-\dfrac{\nabla f(a)^\top u_i}{u_i^\top Qu_i}\,}$ (MT2 Q2, worth 5 marks). The general optimality condition is $U^\top\nabla f(a+Uy)=U^\top(\nabla f(a)+QUy)=0$; conjugacy is what makes it solvable coordinate by coordinate.
- So line-searching along $u_1$, then $u_2$, … (the conjugate direction method) sets $y_1,y_2,\dots$ one at a time, and a later step never changes an earlier $y_i$. (Why the line search at $x^{(k)}$ finds the same $y_k$ as the formula, which uses $\nabla f(a)$: $g^{(k)}=\nabla f(a)+Q(x^{(k)}-a)$, and $x^{(k)}-a$ is a combination of earlier $u_j$, all conjugate to $u_k$, so $g^{(k)\top}u_k=\nabla f(a)^\top u_k$.) After $d$ steps (with $d$ independent directions), $x$ is the minimiser over all of $\mathbb R^d$: $x^{(d)}=x^*$.
For the conjugate direction method $x^{(k+1)}=x^{(k)}+\alpha_ku^{(k)}$ with exact steps $\alpha_k=-\frac{g^{(k)\top}u^{(k)}}{u^{(k)\top}Qu^{(k)}}$:
- $g^{(k)\top}u^{(i)}=0$ for all $i<k$: the new gradient is perpendicular to every direction used so far;
- $x^{(k)}$ minimises $f$ over the whole set $x^{(0)}+\mathrm{span}\{u^{(0)},\dots,u^{(k-1)}\}$ (the "expanding subspace").
It holds for any set of conjugate directions, not just CG's (MT2 T/F (c), "does not apply to arbitrary conjugate directions": False).
C. The conjugate gradient algorithm
C1. The idea: build each direction from the newest gradient
We need conjugate directions, but computing eigenvectors or doing a full Gram–Schmidt is expensive. CG gets them almost for free: start with steepest descent, then each new direction is the new negative gradient plus a little of the previous direction, with the "little" ($\beta_k$) chosen to make it conjugate to the previous one. A small miracle (the CG theorem) makes it conjugate to all earlier ones too.
- Start: $x^{(0)}$ given, $g^{(0)}=Qx^{(0)}-h$, $u^{(0)}=-g^{(0)}$.
- While $g^{(k)}\ne0$: $$\alpha_k=\frac{g^{(k)\top}g^{(k)}}{u^{(k)\top}Qu^{(k)}},\qquad x^{(k+1)}=x^{(k)}+\alpha_ku^{(k)},\qquad g^{(k+1)}=g^{(k)}+\alpha_kQu^{(k)},$$ $$\beta_k=\frac{g^{(k+1)\top}g^{(k+1)}}{g^{(k)\top}g^{(k)}},\qquad u^{(k+1)}=-g^{(k+1)}+\beta_ku^{(k)}.$$
Rationale (MT2 Q3(a)): $\alpha_k$ minimises $f$ along $u^{(k)}$ (exact line search); $\beta_k$ makes $u^{(k+1)}$ $Q$-conjugate to $u^{(k)}$.
Where the two formulas come from (if asked to justify)
Exact line search gives $\alpha_k=-\frac{g^{(k)\top}u^{(k)}}{u^{(k)\top}Qu^{(k)}}$ (section B). Since $u^{(k)}=-g^{(k)}+\beta_{k-1}u^{(k-1)}$ and $g^{(k)\top}u^{(k-1)}=0$ (Expanding Subspace), $-g^{(k)\top}u^{(k)}=g^{(k)\top}g^{(k)}$.
Conjugacy $u^{(k+1)\top}Qu^{(k)}=0$ gives $\beta_k=\frac{g^{(k+1)\top}Qu^{(k)}}{u^{(k)\top}Qu^{(k)}}$; using $Qu^{(k)}=(g^{(k+1)}-g^{(k)})/\alpha_k$ and orthogonality of gradients this simplifies to $\frac{\|g^{(k+1)}\|^2}{\|g^{(k)}\|^2}$.
C2. What CG guarantees (the CG theorem)
- Directions are mutually $Q$-conjugate: $u^{(i)\top}Qu^{(j)}=0$, $i\ne j$.
- Gradients are mutually orthogonal: $g^{(i)\top}g^{(j)}=0$, $i\ne j$. (Orthogonal, not conjugate: a T/F trap.)
- $\mathrm{span}\{g^{(0)},\dots,g^{(k)}\}=\mathrm{span}\{u^{(0)},\dots,u^{(k)}\}=\mathrm{span}\{g^{(0)},Qg^{(0)},\dots,Q^kg^{(0)}\}$. The last set (the start gradient multiplied by powers of $Q$) is called the Krylov space.
- Each $u^{(k)}$ is a descent direction while $g^{(k)}\ne0$: $g^{(k)\top}u^{(k)}=-\|g^{(k)}\|^2+\beta_{k-1}g^{(k)\top}u^{(k-1)}=-\|g^{(k)}\|^2<0$. (Careful: his MT2 key marks the T/F "CG directions are always descent directions" as False. See Practice P4.)
- Finite termination: $x^{(k)}=x^*$ for some $k\le d$ (exact arithmetic).
- Restarting (setting $\beta=0$) every iteration turns CG into steepest descent, so it is slower, not faster (MT2 T/F (e): False).
C3. One full run by hand
- $g^{(0)}=Qx^{(0)}-h=(-2,0)$, so $u^{(0)}=(2,0)$.
- $Qu^{(0)}=(6,2)$, $u^{(0)\top}Qu^{(0)}=12$, $g^{(0)\top}g^{(0)}=4$: $\alpha_0=\frac4{12}=\frac13$. $x^{(1)}=(\frac23,0)$.
- $g^{(1)}=g^{(0)}+\alpha_0Qu^{(0)}=(-2,0)+\frac13(6,2)=(0,\frac23)$. Check: $g^{(1)\top}g^{(0)}=0$ ✓.
- $\beta_0=\frac{4/9}{4}=\frac19$. $u^{(1)}=-g^{(1)}+\frac19u^{(0)}=(\frac29,-\frac23)$. Check conjugacy: $u^{(0)\top}Qu^{(1)}=(2,0)\cdot Qu^{(1)}$ with $Qu^{(1)}=(0,-\frac{16}9)$: $=0$ ✓.
- $u^{(1)\top}Qu^{(1)}=(-\frac23)(-\frac{16}9)=\frac{32}{27}$, $g^{(1)\top}g^{(1)}=\frac49$: $\alpha_1=\frac{4/9}{32/27}=\frac38$.
- $x^{(2)}=(\frac23,0)+\frac38(\frac29,-\frac23)=(\frac34,-\frac14)$. And $Q^{-1}h=\frac18\begin{pmatrix}3&-1\\-1&3\end{pmatrix}(2,0)=(\frac34,-\frac14)$ ✓. Done in 2 steps ($d=2$). Steepest descent from the same start is still about $0.009$ above $f^*$ after 2 steps.
Show answer
$(0,\frac23)\cdot(\frac29,-\frac23)=-\frac49=-\|g^{(1)}\|^2$. Because $u^{(1)}=-g^{(1)}+\beta_0u^{(0)}$ and $g^{(1)}\perp u^{(0)}$: the new direction is a descent direction.
D. How many steps? The polynomial view
"At most $d$" is a weak answer. The exam wants the exact count for a given $Q$ and start. The tool is the polynomial view from class.
D1. CG picks the best polynomial
- Every iterate lies in $x^{(0)}+\mathrm{span}\{g^{(0)},Qg^{(0)},\dots,Q^{k-1}g^{(0)}\}$ (C2), so $x^{(k)}=x^{(0)}+P_{k-1}(Q)g^{(0)}$ for some polynomial $P_{k-1}$ of degree $k-1$.
- Since $g^{(0)}=Q(x^{(0)}-x^*)$: $\;x^{(k)}-x^*=\big(I+QP_{k-1}(Q)\big)(x^{(0)}-x^*)$. Call $R_k(\lambda)=1+\lambda P_{k-1}(\lambda)$: a degree-$k$ polynomial with $R_k(0)=1$.
- Write the start error in eigenvectors: $x^{(0)}-x^*=\sum_ic_iv_i$. A polynomial of $Q$ acts on $v_i$ as the number $R_k(\lambda_i)$ (because $Qv_i=\lambda_iv_i$ gives $Q^2v_i=\lambda_i^2v_i$, and so on). Using that the $v_i$ are orthonormal, $$E(x^{(k)})=\tfrac12\sum_i\lambda_i\,R_k(\lambda_i)^2\,c_i^2 .$$
- By the Expanding Subspace Theorem, CG's $x^{(k)}$ is the best point in that set, i.e. CG uses the best such polynomial. So for any $R_k$ with $R_k(0)=1$:
Only eigenvalues whose $c_i\ne0$ (touched by the start error) matter in the max.
D2. Three consequences, each an exam question
- $r$ distinct eigenvalues ⇒ at most $r$ steps (MT2 Q4(c)). Choose $R_r(\lambda)=\prod_{j=1}^r(1-\lambda/\tau_j)$ over the distinct values $\tau_j$: it is $0$ at every eigenvalue and $R_r(0)=1$. So $E(x^{(r)})=0$.
- Start error touches only some eigenvectors ⇒ only those count (MT2 Q5). If $x^{(0)}-x^*$ (equivalently $g^{(0)}$) lies in the span of $v_5,v_9$, the Krylov space never leaves $\mathrm{span}\{v_5,v_9\}$, and $R_2(\lambda)=(1-\frac\lambda{\lambda_5})(1-\frac\lambda{\lambda_9})$ kills both: 2 steps.
- One step ($k=1$) = steepest descent with exact line search ($u^{(0)}=-g^{(0)}$). Then $P_0=c$ is a constant and the bound is $\min_c\max_i(1+c\lambda_i)^2$. The best $c=-\frac{2}{\lambda_{\min}+\lambda_{\max}}$ gives $\big(\frac{\lambda_{\max}-\lambda_{\min}}{\lambda_{\max}+\lambda_{\min}}\big)^2$, the M1 exact-line-search rate. (This $c$ is a tool for the bound; CG's actual step is at least as good as any $c$, so the bound holds.)
Eigenvalues between 30 and 90. True or false: $E(x^{(1)})\le0.3\,E(x^{(0)})$? Better bound?
- $k=1$: $P_0(\lambda)=c$. Take $c=-\frac{2}{30+90}=-\frac1{60}$.
- Then $1+c\lambda$ runs from $1-\frac{30}{60}=0.5$ to $1-\frac{90}{60}=-0.5$: $|1+c\lambda_i|\le0.5$ for every eigenvalue in $[30,90]$.
- So $E(x^{(1)})\le0.5^2E(x^{(0)})=0.25E(x^{(0)})\le0.3E(x^{(0)})$: True, and $0.25$ is the better bound.
D3. The general rate (for T/F)
For $k$ steps, a Chebyshev polynomial gives $\;\|x^{(k)}-x^*\|_Q\le2\Big(\frac{\sqrt\kappa-1}{\sqrt\kappa+1}\Big)^k\|x^{(0)}-x^*\|_Q$: CG's speed depends on $\sqrt\kappa$, gradient descent's on $\kappa$. For $\kappa=100$, per step in the $Q$-norm $\|z\|_Q=\sqrt{z^\top Qz}$: GD factor $\frac{99}{101}\approx0.98$, CG $\frac{9}{11}\approx0.82$. And after the same number of steps CG is never worse than gradient descent with any step sizes.
E. Structured matrices: $\sigma I+aa^\top+2bb^\top$ and friends
He likes matrices built from a multiple of $I$ plus a few rank-one pieces. Their eigenvalues can be found without any determinant: just apply $Q$ to the obvious vectors.
E1. Eigenvalues by applying $Q$
Let $Q=\sigma I+aa^\top+2bb^\top$ with $\|a\|=\|b\|=1$ and $a^\top b=0$.
- $Qa=\sigma a+a(a^\top a)+2b(b^\top a)=(\sigma+1)a$: eigenvalue $\sigma+1$.
- $Qb=\sigma b+a(a^\top b)+2b(b^\top b)=(\sigma+2)b$: eigenvalue $\sigma+2$.
- Any $w\perp a,b$: $Qw=\sigma w$. That is a $(d-2)$-dimensional space: eigenvalue $\sigma$, repeated $d-2$ times.
So there are at most 3 distinct eigenvalues ($\sigma$, $\sigma+1$, $\sigma+2$; exactly 3 when $d\ge3$), however large $d$ is. CG from any start: at most 3 steps.
E2. Which ones does the start touch?
For $f=\frac12x^\top Qx+w^\top x+c$ (his 2025 sign) started at $x^{(0)}=0$: $g^{(0)}=w$. The count is the number of distinct eigenvalues present in $w$.
$Q=\alpha I+uu^\top+2vv^\top$, $\alpha>0$, $\|u\|=\|v\|=1$, $u^\top v=0$, $f(x)=\frac12x^\top Qx+w^\top x+c$ with $w^\top u=w^\top v=0$.
- (a) Eigenvalues: $\alpha$ ($d-2$ times), $\alpha+1$, $\alpha+2$ (E1).
- (b) Optimum: $Q\succ0$ (all eigenvalues $>0$), so the minimiser solves $Qx+w=0$. Since $w$ lies in the $\alpha$-eigenspace, $Qw=\alpha w$ and $x^*=-\frac1\alpha w$. Value: $f^*=\frac12\cdot\frac{\|w\|^2}{\alpha}-\frac{\|w\|^2}{\alpha}+c=c-\frac{\|w\|^2}{2\alpha}$.
- (b) $\alpha=0$: then $Qw=0$, so $f(tw)=t\|w\|^2+c\to-\infty$ as $t\to-\infty$ (if $w\ne0$): no minimum. (If $w=0$, every $x$ with $Qx=0$ is a minimiser.)
- (c) CG from $x^{(0)}=0$: $g^{(0)}=w$, an eigenvector (eigenvalue $\alpha$). One distinct eigenvalue touched ⇒ 1 iteration. Explicitly $u^{(0)}=-w$, $\alpha_0=\frac{w^\top w}{w^\top Qw}=\frac1\alpha$, $x^{(1)}=-\frac1\alpha w=x^*$, and $g^{(1)}=0$.
Same but $Q=uu^\top+2vv^\top$ (no $\alpha I$), so for $d\ge3$, $Q$ is only positive semidefinite.
- (a) $w\perp u,v$, $x^{(0)}=0$: $g^{(0)}=w$ and $Qw=0$. The first step needs $u^{(0)\top}Qu^{(0)}=w^\top Qw=0$ in the denominator: CG breaks down at the first step. The reason: along $-w$, $f(-tw)=-t\|w\|^2+c\to-\infty$. There is no minimiser at all.
- (b) $w=pu+qv$ with numbers $p^2+q^2=1$ (the paper calls them $\alpha,\beta$): now $g^{(0)}=w$ lives in $\mathrm{span}\{u,v\}$ with eigenvalues 1 and 2. Both touched ($p,q\ne0$) ⇒ 2 iterations, reaching $x=-(pu+\frac q2v)$ (solve $Qx=-w$ inside $\mathrm{span}\{u,v\}$). If $p=0$ or $q=0$: 1 iteration.
E3. Rank-one pieces in general
- $Q=\sigma I+(\text{symmetric rank-}r\text{ matrix})$ ⇒ eigenvalue $\sigma$ on a $(d-r)$-dimensional space, so at most $r+1$ distinct eigenvalues ⇒ CG in at most $r+1$ steps. E.g. $I+aa^\top+bb^\top$ (any $a,b$): at most 3.
- $\frac12(x^\top v_1)^2=\frac12x^\top(v_1v_1^\top)x$ has Hessian $v_1v_1^\top$: rank one, PSD, so convex but not strictly (2021 Q2). Adding $\frac12\|x\|^2$ makes the Hessian $I+v_1v_1^\top\succ0$.
Show answer
$Qa=5a$, and $Qw=3w$ for $w\perp a$: eigenvalues $3,3,3,5$. General start: 2 steps. With $h=4a$: $g^{(0)}=-4a$ touches only eigenvalue 5: 1 step, $x^*=Q^{-1}h=\frac45a$.
F. CG for a linear system $Ax=b$ (2020 P1 Q4)
- Why it works: if $A$ is symmetric positive definite, solving $Ax=b$ is the same as minimising $\phi(x)=\frac12x^\top Ax-b^\top x$, since $\nabla\phi=Ax-b$. The residual $\mathrm{res}(x)=b-Ax$ is minus the gradient. CG on $\phi$ written with residuals $r^{(k)}=b-Ax^{(k)}$ is the algorithm printed in 2020 Q4: $u^{(0)}=r^{(0)}$; $\alpha_k=\frac{\|r^{(k)}\|^2}{u^{(k)\top}Au^{(k)}}$; $x^{(k+1)}=x^{(k)}+\alpha_ku^{(k)}$; $r^{(k+1)}=r^{(k)}-\alpha_kAu^{(k)}$; $\beta_k=\frac{\|r^{(k+1)}\|^2}{\|r^{(k)}\|^2}$; $u^{(k+1)}=r^{(k+1)}+\beta_ku^{(k)}$.
- When it doesn't apply: CG needs $A$ symmetric and positive definite. If $A$ is indefinite, $\phi$ has no minimum and $u^\top Au$ can be $\le0$ (step undefined). If $A$ is not symmetric, $\nabla\phi\ne Ax-b$.
- The fix: apply CG to the normal equations $A^\top Ax=A^\top b$. If $A$ is invertible, $A^\top A$ is symmetric positive definite and has the same solution.
$A_1=\begin{pmatrix}4&1&1\\1&3&2\\1&2&2\end{pmatrix}$, $A_2=\begin{pmatrix}4&1&1\\1&3&2\\1&2&1\end{pmatrix}$. Both are symmetric, so the test is positive definiteness. Sylvester's criterion: a symmetric matrix is PD exactly when all its leading minors (top-left $1\times1$, $2\times2$, … determinants) are positive.
- $A_1$: $4>0$, $4\cdot3-1=11>0$, $\det A_1=4(6-4)-1(2-2)+1(2-3)=7>0$ ⇒ PD: CG applies.
- $A_2$: $4$, $11$, $\det A_2=4(3-4)-1(1-2)+1(2-3)=-4<0$ ⇒ not PD: CG does not apply.
- Modification for both: run CG on $A^\top Ax=A^\top b$ (same style of algorithm, with $A^\top A$ in place of $A$).
G. The exam recipe
- Check the setting: is $Q\succ0$? (Eigenvalues all positive.) If $Q$ is only PSD or indefinite, look for breakdown or unboundedness first (2016 Q4(a), 2025 Q3 with $\alpha=0$).
- Eigen-structure: for $\sigma I+$ rank-one pieces, apply $Q$ to each piece and to vectors perpendicular to all of them (E1). List the distinct eigenvalues and their eigenspaces.
- Write the start $g^{(0)}=Qx^{(0)}-h$ (or $x^{(0)}-x^*$) in those eigenspaces. Count the distinct eigenvalues it touches: that is the number of CG iterations.
- Justify with one line: "the Krylov space stays in the span of those eigenvectors, and $R(\lambda)=\prod(1-\lambda/\tau_j)$ vanishes on them" (or "$r$ distinct eigenvalues ⇒ at most $r$ steps").
- If iterates are asked: run C's five formulas; check $g^{(k+1)}\perp g^{(k)}$ and $u^{(k+1)\top}Qu^{(k)}=0$ as you go.
- Gradients are orthogonal; directions are conjugate. Not the other way round.
- "CG finished in 5 steps ⇒ 5 distinct eigenvalues": False. The start may touch only 5 of more (2025 T/F (i)).
- "At most $d$ steps" needs $Q\succ0$ (and exact arithmetic).
- In his papers $\alpha$ may be a number inside $Q$, not the step length. Read the question's letters.
- His sign convention varies: $f=\frac12x^\top Qx-h^\top x$ (MT2) vs $+w^\top x$ (2025). Then $g^{(0)}$ at $x^{(0)}=0$ is $-h$ or $+w$.
How he asks it (from the papers)
The CG lectures (17–24 Sep) were not recorded, so this comes from his papers and solutions.
- The structured-matrix question is his favourite: 2016 Q4 ($uu^\top+2vv^\top$, singular) → 2025 Q3 ($\alpha I+uu^\top+2vv^\top$). Parts: eigenvalues, optimum, a degenerate case, the CG count from $x^{(0)}=0$, the iterates. Expect it again with a twist (another rank-one piece, a start that touches two eigenspaces, or $\alpha=0$).
- The polynomial view is now standard (MT2 Q4, Q5: 20 of the 45 marks). Know the bound, the one-step $c=-2/(\lambda_{\min}+\lambda_{\max})$ trick, and "only touched eigenvalues count".
- "State the algorithm" and "rationale for $\alpha_k$, $\beta_k$" are cheap marks (2016 Q3, MT2 Q3(a)).
- T/F on CG facts every year: 2024 (d), 2025 (i), MT2 (a)–(e).
Practice (try on paper first, then open the answer)
Past-paper questions first, then new ones. Letters inside a past question follow that paper.
For a given matrix $Q\succ0$, conjugate directions are unique.
- (a) True
- (b) False
Show answer
False. Eigenvectors are one set; $Q$-Gram–Schmidt of any basis gives others (A).
A matrix with columns as conjugate directions has full rank.
- (a) True
- (b) False
Show answer
True (with $Q\succ0$): conjugate nonzero vectors are linearly independent (A, fact 1).
The Expanding Subspace theorem does not apply to arbitrary conjugate directions.
- (a) True
- (b) False
Show answer
False. It holds for any conjugate set with exact line searches (B).
In the CG method the conjugate directions are always descent directions.
- (a) True
- (b) False
Show answer
His key: False. But for CG with exact line search on a quadratic, every direction is a descent direction while $g^{(k)}\ne0$: $g^{(k)\top}u^{(k)}=-\|g^{(k)}\|^2<0$ (C2). So for that setting the key is arguably wrong. It does fit a wider reading: a general set of conjugate directions need not be descent directions (exact line search then just takes a negative $\alpha$), and nonlinear CG with inexact line searches can lose descent. If this sentence appears again, answer as the key does and, if space allows, write the one-line computation for the quadratic case.
Restarting the CG method after every 1 iteration will always lead to faster convergence.
- (a) True
- (b) False
Show answer
False. Restarting every step means $\beta=0$ always: that is steepest descent.
If a conjugate direction method applied to (CQ) finished in 5 iterations, then $Q$ has 5 distinct eigenvalues.
- (a) True
- (b) False
Show answer
False. The start may touch only 5 of more distinct eigenvalues (e.g. eigenvalues $1,\dots,6$ but the start error has no $v_6$ part). And a general conjugate direction method doesn't care about eigenvalues at all: it takes $d$ steps, so $d=5$ is another counterexample.
The Conjugate Gradient algorithm finds the global unconstrained minimum of $h(x)=\frac12x^\top Qx+b^\top x+c$ in at most $d$ iterations.
- (a) True
- (b) False
Show answer
His key: True, for $Q\succ0$ (finite termination, exact arithmetic). Strictly as written ($Q$ only symmetric) it would be false: an indefinite $Q$ has no minimum. If you have room, write "True if $Q\succ0$".
$A\in\mathbb R^{d\times m}$, fixed $a\in\mathbb R^d$, $g(y)=f(a+Ay)$. State the optimality condition (involving $\nabla f(a)$) and solve for $y$ if the columns $a_1,\dots,a_m$ of $A$ are $Q$-conjugate.
Show answer
- $\nabla_yg=A^\top\nabla f(a+Ay)=A^\top(\nabla f(a)+QAy)$; Hessian $A^\top QA\succeq0$, so $g$ is convex and the condition is $A^\top(\nabla f(a)+QAy)=0$.
- Conjugacy makes $A^\top QA$ diagonal: $y_i=-\dfrac{\nabla f(a)^\top a_i}{a_i^\top Qa_i}$ (B).
(a) In CG, $x^{(k+1)}=x^{(k)}+\alpha_ku^{(k)}$, $u^{(k+1)}=-\nabla f(x^{(k+1)})+\beta_ku^{(k)}$. What is the rationale for $\alpha_k$ and $\beta_k$? (b) $v_1,\dots,v_d$ independent. Find $A_{ij}$ so that $u_1=v_1$, $u_i=v_i-\sum_{j<i}A_{ij}u_j$ are $Q$-conjugate.
Show answer
(a) $\alpha_k$ minimises $f$ along $u^{(k)}$; $\beta_k$ makes $u^{(k+1)}$ $Q$-conjugate to $u^{(k)}$. (b) $A_{ij}=\dfrac{v_i^\top Qu_j}{u_j^\top Qu_j}$, from $u_l^\top Qu_i=v_i^\top Qu_l-A_{il}u_l^\top Qu_l=0$ (A).
(a) State a relation between $E(x^{(k)})$ and $E(x^{(0)})$ using the eigenvalues of $Q$. (b) Is $E(x^{(1)})\le0.3E(x^{(0)})$ if the eigenvalues are between 30 and 90? Better bound? (c) If $Q$ has 5 distinct eigenvalues, how many steps until convergence?
Show answer
(a) $E(x^{(k)})\le\max_i(1+\lambda_iP_{k-1}(\lambda_i))^2E(x^{(0)})$ for every polynomial $P_{k-1}$ of degree $k-1$. (b) True; $c=-\frac1{60}$ gives $0.25$ (worked in D). (c) $R_5(\lambda)=\prod_{j=1}^5(1-\lambda/\tau_j)$ vanishes on all eigenvalues: at most 5 steps.
Same setting, $x^{(0)}=0$ and $h=\alpha v_5+\beta v_9$ (eigenvectors of $Q$). (a) Compare $\mathrm{span}(g^{(0)},Qg^{(0)},\dots,Q^kg^{(0)})$ with $\mathrm{span}(v_5,v_9)$. (b) Evaluate $(x^{(0)}-x^*)^\top R_l(Q)(x^{(0)}-x^*)$. (c) Relate $E(x^{(k)})$ to $E(x^{(0)})$ and conclude.
Show answer
- (a) $g^{(0)}=-h\in\mathrm{span}(v_5,v_9)$, and $Q^kg^{(0)}=-\lambda_5^k\alpha v_5-\lambda_9^k\beta v_9$: the Krylov space is inside $\mathrm{span}(v_5,v_9)$.
- (b) $x^{(0)}-x^*=-Q^{-1}h=-\frac{\alpha}{\lambda_5}v_5-\frac\beta{\lambda_9}v_9$, so the value is $R_l(\lambda_5)\frac{\alpha^2}{\lambda_5^2}+R_l(\lambda_9)\frac{\beta^2}{\lambda_9^2}$.
- (c) $E(x^{(0)})=\frac12\big(\frac{\alpha^2}{\lambda_5}+\frac{\beta^2}{\lambda_9}\big)$ (the printed solution drops the $\frac12$; it cancels in the ratio). $E(x^{(k)})=\frac12\big(R_k(\lambda_5)^2\frac{\alpha^2}{\lambda_5}+R_k(\lambda_9)^2\frac{\beta^2}{\lambda_9}\big)\le\max(R_k(\lambda_5)^2,R_k(\lambda_9)^2)E(x^{(0)})$. With $R_2=(1-\frac\lambda{\lambda_5})(1-\frac\lambda{\lambda_9})$: converges in 2 steps.
$a_1,\dots,a_n\in\mathbb R^d$ ($n<d$) are linearly dependent and also $Q$-conjugate, $Q$ real symmetric. Under what conditions on $Q$ is this possible?
Show answer
Only if $Q$ is not positive definite. If $Q\succ0$, conjugate nonzero vectors are independent (proof in A). If some $a_i^\top Qa_i=0$, which needs $Q$ singular or indefinite, it can happen: $Q=\mathrm{diag}(1,0)$, $a_1=e_2$, $a_2=2e_2$.
State the conjugate gradient (CG) algorithm.
Show answer
The five formulas in section C1, with the start $u^{(0)}=-g^{(0)}$ and the stopping rule $g^{(k)}=0$. Name what $\alpha_k$ and $\beta_k$ achieve.
$Q=uu^\top+2vv^\top$, $\|u\|=\|v\|=1$, $u^\top v=0$, $f(x)=\frac12x^\top Qx+w^\top x+c$. (a) $w^\top u=w^\top v=0$: number of CG iterations from $x^{(0)}=0$? (b) What if $w=\alpha u+\beta v$ with $\alpha^2+\beta^2=1$?
Show answer
Worked in E2: (a) breakdown at the first step ($w^\top Qw=0$); $f$ is unbounded below along $-w$, so there is nothing to converge to. (b) 2 iterations if $\alpha,\beta\ne0$ (1 if one is zero), ending at $-(\alpha u+\frac\beta2v)$.
$Q=\alpha I+uu^\top+2vv^\top$, $\alpha>0$, $\|u\|=\|v\|=1$, $u^\top v=0$, $f=\frac12x^\top Qx+w^\top x+c$, $w^\top u=w^\top v=0$. (a) Eigenvalues of $Q$. (b) Global optimum point and value; the case $\alpha=0$. (c) CG from $x^{(0)}=0$: iterations and all iterates.
Show answer
Worked in E2: (a) $\alpha$ ($d-2$ times), $\alpha+1$, $\alpha+2$. (b) $x^*=-w/\alpha$, $f^*=c-\frac{\|w\|^2}{2\alpha}$; $\alpha=0$: unbounded below if $w\ne0$. (c) One iteration: $x^{(1)}=-w/\alpha$.
$v_1^\top v_2=0$ (both nonzero), $f(x)=\frac12(x^\top v_1)^2+\alpha v_2^\top x$. (a) Hessian? Convex? (b) Global minima for all $\alpha$. (c) Repeat for $g(x)=f(x)+\frac12\|x\|^2$.
Show answer
- (a) $\nabla^2f=v_1v_1^\top\succeq0$ (rank one): convex, not strictly.
- (b) $\alpha=0$: $f\ge0$ with $f^*=0$ on the whole hyperplane $\{x:v_1^\top x=0\}$ (infinitely many minimisers). $\alpha\ne0$: $f(tv_2)=\alpha t\|v_2\|^2$ (because $v_1^\top v_2=0$) $\to-\infty$ for suitable sign of $t$: no minimum.
- (c) $\nabla^2g=I+v_1v_1^\top\succ0$: strictly convex. $\nabla g=v_1(v_1^\top x)+\alpha v_2+x=0$. Dot with $v_1$: $(1+\|v_1\|^2)v_1^\top x=0$, so $v_1^\top x=0$ and $x^*=-\alpha v_2$, $g^*=-\frac{\alpha^2}2\|v_2\|^2$.
The residual form of CG for $Ax=b$ ($u^{(0)}=\mathrm{res}(x^{(0)})$, $\alpha_k=\frac{\|\mathrm{res}(x^{(k)})\|^2}{u^{(k)\top}Au^{(k)}}$, …). (a) Why does it solve the system? (b) For $A_1$, $A_2$ (section F) it applies to only one: which and why? Modify it to apply to both.
Show answer
Worked in F: (a) for symmetric PD $A$ it is CG on $\frac12x^\top Ax-b^\top x$, whose minimiser solves $Ax=b$, and $\mathrm{res}=-\nabla$; finite termination. (b) $A_1$ (PD by leading minors $4,11,7$); $A_2$ has $\det=-4$. Use $A^\top Ax=A^\top b$.
$Q=2I+aa^\top+bb^\top$ in $\mathbb R^6$ with $a,b$ linearly independent but not orthogonal. (a) How many distinct eigenvalues can $Q$ have at most? (b) Maximum CG iterations from any start? (c) From $x^{(0)}$ with $x^{(0)}-x^*\perp a,b$?
Show answer
(a) For $w\perp a,b$: $Qw=2w$, a 4-dimensional eigenspace. $Q$ maps $\mathrm{span}\{a,b\}$ into itself and is symmetric, so the remaining two eigenvectors lie in that plane, with eigenvalues $2+\mu$ where $\mu>0$ are the eigenvalues of $aa^\top+bb^\top$ there. So at most 3 distinct eigenvalues. (b) 3. (c) The start error is in the eigenvalue-2 eigenspace: 1 step.
$Q=\mathrm{diag}(2,2,5)$, $f=\frac12x^\top Qx-h^\top x$, $x^{(0)}=0$. (a) $h=(2,0,5)$: $x^*$ and the number of CG steps. (b) $h=(2,4,0)$?
Show answer
(a) $x^*=(1,0,1)$; $g^{(0)}=-h$ touches eigenvalues 2 and 5: 2 steps. (b) $g^{(0)}=-(2,4,0)$ lies in the eigenvalue-2 eigenspace: 1 step, to $x^*=(1,2,0)$.
CG on $f=\frac12x^\top(5I)x-h^\top x$ converges in one iteration from any start.
- (a) True
- (b) False
Show answer
True. One distinct eigenvalue (and the first step is the steepest-descent step, which for $Q=\lambda I$ lands on $x^*$: M1, F3).
The gradients produced by CG are mutually $Q$-conjugate.
- (a) True
- (b) False
Show answer
False. Gradients are mutually orthogonal; the directions are conjugate.
The first CG step from $x^{(0)}$ is the same as one step of steepest descent with exact line search.
- (a) True
- (b) False
Show answer
True. $u^{(0)}=-g^{(0)}$ and $\alpha_0$ is the exact step.
CG can be applied directly to $Ax=b$ for any symmetric invertible $A$.
- (a) True
- (b) False
Show answer
False. It needs positive definiteness (2020 $A_2$ is symmetric, invertible, and indefinite). Use the normal equations.
After $k$ iterations from the same start, CG has a function value no larger than gradient descent with any choice of $k$ step sizes.
- (a) True
- (b) False
Show answer
True. Gradient descent's $k$-th iterate also lies in $x^{(0)}+$ the Krylov space, where CG's iterate is the best point (D1, D3).
Self-test (no looking)
Define $Q$-conjugate and prove conjugate ⇒ independent (for $Q\succ0$).
Show answer
$u_i^\top Qu_j=0$, $i\ne j$. If $\sum c_ju_j=0$, multiply by $u_i^\top Q$: $c_iu_i^\top Qu_i=0$, and $u_i^\top Qu_i>0$, so $c_i=0$.
Write the CG algorithm (all five update formulas).
Show answer
$\alpha_k=\frac{\|g^{(k)}\|^2}{u^{(k)\top}Qu^{(k)}}$, $x^{(k+1)}=x^{(k)}+\alpha_ku^{(k)}$, $g^{(k+1)}=g^{(k)}+\alpha_kQu^{(k)}$, $\beta_k=\frac{\|g^{(k+1)}\|^2}{\|g^{(k)}\|^2}$, $u^{(k+1)}=-g^{(k+1)}+\beta_ku^{(k)}$; start $u^{(0)}=-g^{(0)}$.
State the polynomial bound and the "distinct eigenvalues" consequence.
Show answer
$E(x^{(k)})\le\max_i(1+\lambda_iP_{k-1}(\lambda_i))^2E(x^{(0)})$; with $r$ distinct eigenvalues, $R_r=\prod(1-\lambda/\tau_j)$ gives $E(x^{(r)})=0$.
Eigenvalues of $5I+3pp^\top$ ($\|p\|=1$) in $\mathbb R^{10}$, and the CG count from a generic start.
Show answer
$8$ (along $p$) and $5$ (9 times): 2 distinct, so 2 steps.
Best one-step bound when the eigenvalues are in $[2,8]$?
Show answer
$c=-\frac2{10}$, $\max|1+c\lambda|=0.6$, bound $0.36$.
Summary card
- Conjugate: $u_i^\top Qu_j=0$ ($i\ne j$). With $Q\succ0$: independent, at most $d$, full rank, not unique. Without PD: can be dependent (2016 Q2).
- Gram–Schmidt with $Q$: $u_i=v_i-\sum_{j<i}\frac{v_i^\top Qu_j}{u_j^\top Qu_j}u_j$.
- Decoupling: $\min_yf(a+Uy)$ with conjugate columns: $y_i=-\frac{\nabla f(a)^\top u_i}{u_i^\top Qu_i}$. Conjugate direction method ⇒ at most $d$ steps.
- Expanding Subspace: $g^{(k)}\perp u^{(i)}$ for $i<k$; $x^{(k)}$ minimises over $x^{(0)}+\mathrm{span}\{u^{(0..k-1)}\}$. Any conjugate set.
- CG: $u^{(0)}=-g^{(0)}$; $\alpha_k=\frac{\|g^{(k)}\|^2}{u^{(k)\top}Qu^{(k)}}$; $g^{(k+1)}=g^{(k)}+\alpha_kQu^{(k)}$; $\beta_k=\frac{\|g^{(k+1)}\|^2}{\|g^{(k)}\|^2}$; $u^{(k+1)}=-g^{(k+1)}+\beta_ku^{(k)}$. Gradients orthogonal, directions conjugate, span = Krylov space.
- Bound: $E(x^{(k)})\le\max_i(1+\lambda_iP_{k-1}(\lambda_i))^2E(x^{(0)})$. One step: $c=-\frac2{\lambda_{\min}+\lambda_{\max}}$ gives $(\frac{\lambda_{\max}-\lambda_{\min}}{\lambda_{\max}+\lambda_{\min}})^2$. General: factor $\frac{\sqrt\kappa-1}{\sqrt\kappa+1}$.
- Count: steps = number of distinct eigenvalues touched by the start error ($\le$ number of distinct eigenvalues $\le d$).
- Structured: $\sigma I+aa^\top+2bb^\top$ (orthonormal $a,b$): $\sigma$ ($d-2$×), $\sigma+1$, $\sigma+2$. $\sigma I+$ rank $r$ ⇒ at most $r+1$ distinct. Singular $Q$ with $w\notin$ range: unbounded below; CG breaks down ($u^\top Qu=0$) at once if $w$ is in the null space, otherwise once the range part is solved.
- Linear systems: CG needs $A$ symmetric PD (check leading minors); otherwise use $A^\top Ax=A^\top b$.