Algorithm Search⌘K

Proofs: Conjugate gradient method

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⁡0 < \lambda_{\min} \le \lambda_{\max} are the extreme eigenvalues of AA and κ=λmax⁡/λmin⁡\kappa = \lambda_{\max}/\lambda_{\min}. Pk1\mathcal{P}_k^1 is the set of real polynomials qq of degree at most kk with q(0)=1q(0) = 1.

Lemma 1. As long as CG has not stopped, ∥ek∥A=min⁡q∈Pk1∥q(A)e0∥A\|e_k\|_A = \min_{q \in \mathcal{P}_k^1} \|q(A) e_0\|_A.

Proof. y∈x0+Kk(A,r0)y \in x_0 + \mathcal{K}_k(A, r_0) exactly when x−y=e0−s(A)r0x - y = e_0 - s(A) r_0 for a polynomial ss of degree at most k−1k - 1. Since r0=Ae0r_0 = A e_0, this is x−y=q(A)e0x - y = q(A) e_0 with q(t)=1−ts(t)q(t) = 1 - t s(t), and the map s↦qs \mapsto q is a bijection onto Pk1\mathcal{P}_k^1. Corollary 1 of the correctness proof says that xkx_k minimizes ∥x−y∥A\|x - y\|_A over these yy. □\square

Lemma 2. For each qq, ∥q(A)e0∥A≤max⁡λ∈[λmin⁡,λmax⁡]∣q(λ)∣ ∥e0∥A\|q(A) e_0\|_A \le \max_{\lambda \in [\lambda_{\min}, \lambda_{\max}]} |q(\lambda)| \, \|e_0\|_A.

Proof. Let A=VΛVTA = V \Lambda V^T with VV orthogonal and e0=Vce_0 = V c. Then ∥q(A)e0∥A2=∑iλiq(λi)2ci2≤max⁡iq(λi)2∑iλici2\|q(A) e_0\|_A^2 = \sum_i \lambda_i q(\lambda_i)^2 c_i^2 \le \max_i q(\lambda_i)^2 \sum_i \lambda_i c_i^2, and ∑iλici2=∥e0∥A2\sum_i \lambda_i c_i^2 = \|e_0\|_A^2. Each λi\lambda_i lies in the interval. □\square

Theorem. ∥ek∥A≤2(κ−1κ+1)k∥e0∥A\|e_k\|_A \le 2 \left( \frac{\sqrt\kappa - 1}{\sqrt\kappa + 1} \right)^k \|e_0\|_A. Consequently ∥ek∥A≤ε∥e0∥A\|e_k\|_A \le \varepsilon \|e_0\|_A for each k≥12κln⁡(2/ε)k \ge \tfrac12 \sqrt\kappa \ln(2/\varepsilon), 0<ε≤10 < \varepsilon \le 1.

Proof. If κ=1\kappa = 1 then A=λIA = \lambda I, r1=0r_1 = 0 and the bound holds for k≥1k \ge 1 (and for k=0k = 0 trivially). Let κ>1\kappa > 1. Let TkT_k be the Chebyshev polynomial of degree kk: Tk(cos⁡θ)=cos⁡(kθ)T_k(\cos\theta) = \cos(k\theta), so ∣Tk(t)∣≤1|T_k(t)| \le 1 on [−1,1][-1, 1], and for ∣t∣≥1|t| \ge 1, Tk(t)=12[(t+t2−1)k+(t−t2−1)k]T_k(t) = \tfrac12 \bigl[(t + \sqrt{t^2 - 1})^k + (t - \sqrt{t^2 - 1})^k\bigr]. Put σ=(λmax⁡+λmin⁡)/(λmax⁡−λmin⁡)=(κ+1)/(κ−1)>1\sigma = (\lambda_{\max} + \lambda_{\min})/(\lambda_{\max} - \lambda_{\min}) = (\kappa + 1)/(\kappa - 1) > 1 and

q(λ)=Tk((λmax⁡+λmin⁡−2λ)/(λmax⁡−λmin⁡))Tk(σ).q(\lambda) = \frac{T_k\bigl((\lambda_{\max} + \lambda_{\min} - 2\lambda)/(\lambda_{\max} - \lambda_{\min})\bigr)}{T_k(\sigma)}.

Then q(0)=1q(0) = 1, qq has degree kk, and the argument of TkT_k in the numerator lies in [−1,1][-1, 1] for λ\lambda in the interval. So max⁡∣q∣≤1/Tk(σ)\max |q| \le 1/T_k(\sigma) there. Both terms of the formula for Tk(σ)T_k(\sigma) are positive, so Tk(σ)≥12(σ+σ2−1)kT_k(\sigma) \ge \tfrac12 (\sigma + \sqrt{\sigma^2 - 1})^k. Now σ2−1=4κ/(κ−1)2\sigma^2 - 1 = 4\kappa/(\kappa - 1)^2, so

σ+σ2−1=κ+1+2κκ−1=(κ+1)2(κ−1)(κ+1)=κ+1κ−1.\sigma + \sqrt{\sigma^2 - 1} = \frac{\kappa + 1 + 2\sqrt\kappa}{\kappa - 1} = \frac{(\sqrt\kappa + 1)^2}{(\sqrt\kappa - 1)(\sqrt\kappa + 1)} = \frac{\sqrt\kappa + 1}{\sqrt\kappa - 1}.

Lemmas 1 and 2 give the first claim.

For the second, let t=1/κ∈(0,1)t = 1/\sqrt\kappa \in (0, 1). Then ln⁡κ+1κ−1=ln⁡1+t1−t=2(t+t3/3+t5/5+⋯ )≥2t\ln\frac{\sqrt\kappa + 1}{\sqrt\kappa - 1} = \ln\frac{1 + t}{1 - t} = 2(t + t^3/3 + t^5/5 + \cdots) \ge 2t. So 2(κ−1κ+1)k≤2e−2k/κ≤ε2 \bigl(\frac{\sqrt\kappa - 1}{\sqrt\kappa + 1}\bigr)^k \le 2 e^{-2k/\sqrt\kappa} \le \varepsilon when k≥12κln⁡(2/ε)k \ge \tfrac12 \sqrt\kappa \ln(2/\varepsilon). ■\blacksquare

Cost. Each pass of line L2 does one product with AA, and the start does one more. So reducing the AA-norm of the error by ε\varepsilon takes at most ⌈12κln⁡(2/ε)⌉+1\lceil \tfrac12 \sqrt\kappa \ln(2/\varepsilon) \rceil + 1 products in exact arithmetic, and O((z+n)κlog⁡(2/ε))O((z + n)\sqrt\kappa \log(2/\varepsilon)) flops for a matrix with zz nonzeros.

CG produces orthogonal residuals and conjugate directions, minimizes the A-norm error and terminates full

This proof shows: correctness, termination.

Exact arithmetic. AA is symmetric positive definite, xx solves Ax=bA x = b, and rk,pk,xk,αk,βk,ρk=rkTrkr_k, p_k, x_k, \alpha_k, \beta_k, \rho_k = r_k^T r_k are the values of the pseudocode after kk passes (with tolerance 00, so the loop stops only when rk=0r_k = 0). Write Kk=Kk(A,r0)\mathcal{K}_k = \mathcal{K}_k(A, r_0) and ⟨v,w⟩A=vTAw\langle v, w \rangle_A = v^T A w, an inner product because AA is positive definite.

Theorem. Let k≥1k \ge 1 and assume r0,…,rk−1r_0, \ldots, r_{k-1} are all nonzero. Then:

  • (S) span⁡{r0,…,rk−1}=span⁡{p0,…,pk−1}=Kk\operatorname{span}\{r_0, \ldots, r_{k-1}\} = \operatorname{span}\{p_0, \ldots, p_{k-1}\} = \mathcal{K}_k, and xk−x0∈Kkx_k - x_0 \in \mathcal{K}_k;
  • (O) rkTpj=0r_k^T p_j = 0 and rkTrj=0r_k^T r_j = 0 for all j<kj < k;
  • (C) pkTApj=0p_k^T A p_j = 0 for all j<kj < k;
  • (P) pj≠0p_j \ne 0 and pjTApj>0p_j^T A p_j > 0 for j<kj < k, so each αj\alpha_j is defined, and αj=ρj/(pjTApj)\alpha_j = \rho_j / (p_j^T A p_j) with ρj=rjTpj\rho_j = r_j^T p_j.

Proof. Induction on kk.

Base k=1k = 1. p0=r0≠0p_0 = r_0 \ne 0, so p0TAp0>0p_0^T A p_0 > 0 and (P) holds; K1=span⁡{r0}\mathcal{K}_1 = \operatorname{span}\{r_0\} and x1−x0=α0p0x_1 - x_0 = \alpha_0 p_0, so (S) holds. r1Tp0=r0Tr0−α0p0TAp0=ρ0−ρ0=0r_1^T p_0 = r_0^T r_0 - \alpha_0 p_0^T A p_0 = \rho_0 - \rho_0 = 0, and r0=p0r_0 = p_0, so (O) holds. p1TAp0=r1TAp0+β0p0TAp0p_1^T A p_0 = r_1^T A p_0 + \beta_0 p_0^T A p_0. From line L7, Ap0=(r0−r1)/α0A p_0 = (r_0 - r_1)/\alpha_0, so r1TAp0=(r1Tr0−ρ1)/α0=−ρ1/α0r_1^T A p_0 = (r_1^T r_0 - \rho_1)/\alpha_0 = -\rho_1/\alpha_0, and p0TAp0=ρ0/α0p_0^T A p_0 = \rho_0/\alpha_0. With β0=ρ1/ρ0\beta_0 = \rho_1/\rho_0 the sum is −ρ1/α0+ρ1/α0=0-\rho_1/\alpha_0 + \rho_1/\alpha_0 = 0, so (C) holds.

Step. Assume the statements for 1,…,k1, \ldots, k and that rk≠0r_k \ne 0; we prove them for k+1k + 1.

(P) for j=kj = k: by (O), rkTpk−1=0r_k^T p_{k-1} = 0, so ∥pk∥22=∥rk+βk−1pk−1∥22=∥rk∥22+βk−12∥pk−1∥22≥∥rk∥22>0\|p_k\|_2^2 = \|r_k + \beta_{k-1} p_{k-1}\|_2^2 = \|r_k\|_2^2 + \beta_{k-1}^2 \|p_{k-1}\|_2^2 \ge \|r_k\|_2^2 > 0. So pk≠0p_k \ne 0 and pkTApk>0p_k^T A p_k > 0. Also rkTpk=rkTrk+βk−1rkTpk−1=ρkr_k^T p_k = r_k^T r_k + \beta_{k-1} r_k^T p_{k-1} = \rho_k.

(S): pk=rk+βk−1pk−1p_k = r_k + \beta_{k-1} p_{k-1} and rk=rk−1−αk−1Apk−1r_k = r_{k-1} - \alpha_{k-1} A p_{k-1}, with Apk−1∈AKk⊆Kk+1A p_{k-1} \in A \mathcal{K}_k \subseteq \mathcal{K}_{k+1}. So rk,pk∈Kk+1r_k, p_k \in \mathcal{K}_{k+1} and the spans of the first k+1k+1 residuals and directions lie in Kk+1\mathcal{K}_{k+1}. The directions p0,…,pkp_0, \ldots, p_k are nonzero and pairwise AA-orthogonal by (C) and (P), so they are linearly independent, and their span has dimension k+1≥dim⁡Kk+1k + 1 \ge \dim \mathcal{K}_{k+1}. So all three spaces are equal. The residuals r0,…,rkr_0, \ldots, r_k are nonzero and pairwise orthogonal by (O), so they span the same space too. Finally xk+1−x0=(xk−x0)+αkpk∈Kk+1x_{k+1} - x_0 = (x_k - x_0) + \alpha_k p_k \in \mathcal{K}_{k+1}.

(O): rk+1=rk−αkApkr_{k+1} = r_k - \alpha_k A p_k. For j<kj < k, rk+1Tpj=rkTpj−αkpkTApj=0−0r_{k+1}^T p_j = r_k^T p_j - \alpha_k p_k^T A p_j = 0 - 0 by (O) and (C). For j=kj = k, rk+1Tpk=ρk−αkpkTApk=0r_{k+1}^T p_k = \rho_k - \alpha_k p_k^T A p_k = 0 by the formula for αk\alpha_k. So rk+1r_{k+1} is orthogonal to p0,…,pkp_0, \ldots, p_k, hence to Kk+1\mathcal{K}_{k+1} by (S), hence to r0,…,rkr_0, \ldots, r_k.

(C): pk+1TApj=rk+1TApj+βkpkTApjp_{k+1}^T A p_j = r_{k+1}^T A p_j + \beta_k p_k^T A p_j. For j<kj < k: Apj∈Kj+2⊆Kk+1A p_j \in \mathcal{K}_{j+2} \subseteq \mathcal{K}_{k+1}, so the first term is 00 by (O), and the second is 00 by (C). For j=kj = k: the computation of the base case, with kk in place of 00, gives rk+1TApk=−ρk+1/αkr_{k+1}^T A p_k = -\rho_{k+1}/\alpha_k and βkpkTApk=(ρk+1/ρk)(ρk/αk)\beta_k p_k^T A p_k = (\rho_{k+1}/\rho_k)(\rho_k/\alpha_k), which sum to 00. □\square

Corollary 1 (optimality). Under the same assumption, xkx_k is the unique minimizer of ∥x−y∥A\|x - y\|_A over y∈x0+Kky \in x_0 + \mathcal{K}_k.

Proof. Let ek=x−xke_k = x - x_k; then Aek=rkA e_k = r_k. For y=xk+wy = x_k + w with w∈Kkw \in \mathcal{K}_k, ∥x−y∥A2=∥ek∥A2−2wTAek+∥w∥A2=∥ek∥A2−2wTrk+∥w∥A2\|x - y\|_A^2 = \|e_k\|_A^2 - 2 w^T A e_k + \|w\|_A^2 = \|e_k\|_A^2 - 2 w^T r_k + \|w\|_A^2. By (O) and (S), wTrk=0w^T r_k = 0. So ∥x−y∥A2=∥ek∥A2+∥w∥A2\|x - y\|_A^2 = \|e_k\|_A^2 + \|w\|_A^2, which is smallest exactly for w=0w = 0; and xk∈x0+Kkx_k \in x_0 + \mathcal{K}_k by (S). □\square

Corollary 2 (termination). Some rkr_k with k≤nk \le n is zero, so CG returns xx after at most nn passes of line L2 (if maxit ≥n+1\ge n + 1).

Proof. If r0,…,rn−1r_0, \ldots, r_{n-1} were all nonzero, then by (O) rnr_n is orthogonal to the nn nonzero, pairwise orthogonal vectors r0,…,rn−1r_0, \ldots, r_{n-1}, which span Rn\mathbb{R}^n, so rn=0r_n = 0. If rk=0r_k = 0, line L3 returns xkx_k, and Axk=bA x_k = b. □\square

Remark (fewer steps). Write r0=∑icivir_0 = \sum_i c_i v_i in an orthonormal eigenbasis of AA, and let dd be the number of distinct eigenvalues λ\lambda with some ci≠0c_i \ne 0 for viv_i in the eigenspace of λ\lambda. Then Kk\mathcal{K}_k lies in the span of the dd vectors ∑λi=λcivi\sum_{\lambda_i = \lambda} c_i v_i, so dim⁡Kk≤d\dim \mathcal{K}_k \le d, and the argument of Corollary 2 within this space gives rd=0r_d = 0. ■\blacksquare

Back to Conjugate gradient method