These are the human proofs of Conjugate gradient method, at full length.
The Chebyshev bound on the error of CG full
This proof shows: matvecs.worst.
Exact arithmetic, notation of the correctness proof. 0<λmin≤λmax are the extreme eigenvalues of A and κ=λmax/λmin. Pk1 is the set of real polynomials q of degree at most k with q(0)=1.
Lemma 1. As long as CG has not stopped, ∥ek∥A=minq∈Pk1∥q(A)e0∥A.
Proof.y∈x0+Kk(A,r0) exactly when x−y=e0−s(A)r0 for a polynomial s of degree at most k−1. Since r0=Ae0, this is x−y=q(A)e0 with q(t)=1−ts(t), and the map s↦q is a bijection onto Pk1. Corollary 1 of the correctness proof says that xk minimizes ∥x−y∥A over these y. □
Lemma 2. For each q, ∥q(A)e0∥A≤maxλ∈[λmin,λmax]∣q(λ)∣∥e0∥A.
Proof. Let A=VΛVT with V orthogonal and e0=Vc. Then ∥q(A)e0∥A2=∑iλiq(λi)2ci2≤maxiq(λi)2∑iλici2, and ∑iλici2=∥e0∥A2. Each λi lies in the interval. □
Theorem.∥ek∥A≤2(κ+1κ−1)k∥e0∥A. Consequently ∥ek∥A≤ε∥e0∥A for each k≥21κln(2/ε), 0<ε≤1.
Proof. If κ=1 then A=λI, r1=0 and the bound holds for k≥1 (and for k=0 trivially). Let κ>1. Let Tk be the Chebyshev polynomial of degree k: Tk(cosθ)=cos(kθ), so ∣Tk(t)∣≤1 on [−1,1], and for ∣t∣≥1, Tk(t)=21[(t+t2−1)k+(t−t2−1)k]. Put σ=(λmax+λmin)/(λmax−λmin)=(κ+1)/(κ−1)>1 and
q(λ)=Tk(σ)Tk((λmax+λmin−2λ)/(λmax−λmin)).
Then q(0)=1, q has degree k, and the argument of Tk in the numerator lies in [−1,1] for λ in the interval. So max∣q∣≤1/Tk(σ) there. Both terms of the formula for Tk(σ) are positive, so Tk(σ)≥21(σ+σ2−1)k. Now σ2−1=4κ/(κ−1)2, so
For the second, let t=1/κ∈(0,1). Then lnκ−1κ+1=ln1−t1+t=2(t+t3/3+t5/5+⋯)≥2t. So 2(κ+1κ−1)k≤2e−2k/κ≤ε when k≥21κln(2/ε). ■
Cost. Each pass of line L2 does one product with A, and the start does one more. So reducing the A-norm of the error by ε takes at most ⌈21κln(2/ε)⌉+1 products in exact arithmetic, and O((z+n)κlog(2/ε)) flops for a matrix with z nonzeros.
CG produces orthogonal residuals and conjugate directions, minimizes the A-norm error and terminates full
This proof shows: correctness, termination.
Exact arithmetic. A is symmetric positive definite, x solves Ax=b, and rk,pk,xk,αk,βk,ρk=rkTrk are the values of the pseudocode after k passes (with tolerance 0, so the loop stops only when rk=0). Write Kk=Kk(A,r0) and ⟨v,w⟩A=vTAw, an inner product because A is positive definite.
Theorem. Let k≥1 and assume r0,…,rk−1 are all nonzero. Then:
(S) span{r0,…,rk−1}=span{p0,…,pk−1}=Kk, and xk−x0∈Kk;
(O) rkTpj=0 and rkTrj=0 for all j<k;
(C) pkTApj=0 for all j<k;
(P) pj=0 and pjTApj>0 for j<k, so each αj is defined, and αj=ρj/(pjTApj) with ρj=rjTpj.
Proof. Induction on k.
Base k=1.p0=r0=0, so p0TAp0>0 and (P) holds; K1=span{r0} and x1−x0=α0p0, so (S) holds. r1Tp0=r0Tr0−α0p0TAp0=ρ0−ρ0=0, and r0=p0, so (O) holds. p1TAp0=r1TAp0+β0p0TAp0. From line L7, Ap0=(r0−r1)/α0, so r1TAp0=(r1Tr0−ρ1)/α0=−ρ1/α0, and p0TAp0=ρ0/α0. With β0=ρ1/ρ0 the sum is −ρ1/α0+ρ1/α0=0, so (C) holds.
Step. Assume the statements for 1,…,k and that rk=0; we prove them for k+1.
(P) for j=k: by (O), rkTpk−1=0, so ∥pk∥22=∥rk+βk−1pk−1∥22=∥rk∥22+βk−12∥pk−1∥22≥∥rk∥22>0. So pk=0 and pkTApk>0. Also rkTpk=rkTrk+βk−1rkTpk−1=ρk.
(S): pk=rk+βk−1pk−1 and rk=rk−1−αk−1Apk−1, with Apk−1∈AKk⊆Kk+1. So rk,pk∈Kk+1 and the spans of the first k+1 residuals and directions lie in Kk+1. The directions p0,…,pk are nonzero and pairwise A-orthogonal by (C) and (P), so they are linearly independent, and their span has dimension k+1≥dimKk+1. So all three spaces are equal. The residuals r0,…,rk are nonzero and pairwise orthogonal by (O), so they span the same space too. Finally xk+1−x0=(xk−x0)+αkpk∈Kk+1.
(O): rk+1=rk−αkApk. For j<k, rk+1Tpj=rkTpj−αkpkTApj=0−0 by (O) and (C). For j=k, rk+1Tpk=ρk−αkpkTApk=0 by the formula for αk. So rk+1 is orthogonal to p0,…,pk, hence to Kk+1 by (S), hence to r0,…,rk.
(C): pk+1TApj=rk+1TApj+βkpkTApj. For j<k: Apj∈Kj+2⊆Kk+1, so the first term is 0 by (O), and the second is 0 by (C). For j=k: the computation of the base case, with k in place of 0, gives rk+1TApk=−ρk+1/αk and βkpkTApk=(ρk+1/ρk)(ρk/αk), which sum to 0. □
Corollary 1 (optimality). Under the same assumption, xk is the unique minimizer of ∥x−y∥A over y∈x0+Kk.
Proof. Let ek=x−xk; then Aek=rk. For y=xk+w with w∈Kk, ∥x−y∥A2=∥ek∥A2−2wTAek+∥w∥A2=∥ek∥A2−2wTrk+∥w∥A2. By (O) and (S), wTrk=0. So ∥x−y∥A2=∥ek∥A2+∥w∥A2, which is smallest exactly for w=0; and xk∈x0+Kk by (S). □
Corollary 2 (termination). Some rk with k≤n is zero, so CG returns x after at most n passes of line L2 (if maxit ≥n+1).
Proof. If r0,…,rn−1 were all nonzero, then by (O) rn is orthogonal to the n nonzero, pairwise orthogonal vectors r0,…,rn−1, which span Rn, so rn=0. If rk=0, line L3 returns xk, and Axk=b. □
Remark (fewer steps). Write r0=∑icivi in an orthonormal eigenbasis of A, and let d be the number of distinct eigenvalues λ with some ci=0 for vi in the eigenspace of λ. Then Kk lies in the span of the d vectors ∑λi=λcivi, so dimKk≤d, and the argument of Corollary 2 within this space gives rd=0. ■