advanced33 min studyLesson 307 in Mathematics

Conjugate gradients and preconditioning

Exploit positive-definite geometry, energy minimization, and a compatible preconditioner.

On this page

What you’ll understand

  • Execute conjugate-gradient steps for a symmetric positive definite system.
  • Interpret the A-norm minimization and its condition-number bound.
  • Choose a positive definite preconditioning model without confusing multiplication by an inverse with forming it.

Symmetric positive definite systems have a geometry that a general-purpose solver need not exploit. Their solution uniquely minimizes a strictly convex quadratic, and conjugate gradients searches successive Krylov spaces using directions orthogonal in that quadratic's metric. A short recurrence replaces the growing Arnoldi basis in exact arithmetic. Preconditioning can improve the relevant geometry, but only if its structure and application are compatible with the algorithm's assumptions.

The energy norm connects a solve to a minimization problem

Let A be real symmetric positive definite. The quadratic q(x)=xᵀAx/2−bᵀx has gradient Ax−b and a unique minimizer xstar satisfying Axstar=b. Its excess value is one half the squared A-norm of the error, where the A-norm of e is the square root of eᵀAe. Conjugate gradients chooses the kth iterate from the initial guess plus its kth residual Krylov space to minimize that energy error in exact arithmetic. It does not generally minimize the ordinary Euclidean residual norm at every step.

The search directions are A-conjugate: distinct directions have zero cross product pᵢᵀApⱼ. Residuals are mutually Euclidean-orthogonal under exact arithmetic until termination. These are different orthogonality statements and explain the short update formulas. Positive definiteness makes pᵀAp positive for nonzero p, so the step denominator has the required sign. Symmetry alone is insufficient; an indefinite matrix can break that argument. Specialized algorithms exist for other structures, but the standard CG guarantee should not be transferred to them without modification.

αk=rkTrkpkTApk,xk+1=xk+αkpk,rk+1=rk−αkApk,βk=rk+1Trk+1rkTrk,pk+1=rk+1+βkpk\alpha_k=\frac{r_k^{\mathsf T}r_k}{p_k^{\mathsf T}Ap_k},\quad x_{k+1}=x_k+\alpha_kp_k,\quad r_{k+1}=r_k-\alpha_kAp_k,\quad \beta_k=\frac{r_{k+1}^{\mathsf T}r_{k+1}}{r_k^{\mathsf T}r_k},\quad p_{k+1}=r_{k+1}+\beta_kp_k
For unpreconditioned CG use r₀=b−Ax₀ and p₀=r₀, with A symmetric positive definite. Stop when the residual is zero instead of continuing a formula with a zero denominator.↔ Scroll wide equations horizontally.

A worst-case bound is useful but can be pessimistic

In exact arithmetic, the error admits a polynomial representation whose polynomial equals one at zero. Bounding that polynomial over the positive eigenvalue interval gives the familiar condition-number convergence estimate. The square root of κ₂ appears, making the bound stronger than the corresponding simple fixed-step gradient iteration estimate. The factor depends only on the extreme eigenvalues, so it ignores clustering and the starting error's spectral components. A system can converge much faster than this interval-based worst-case statement predicts.

CG terminates in at most n steps in exact arithmetic for an n-dimensional positive definite problem, and potentially earlier when the effective spectral support is smaller. Finite precision destroys exact orthogonality and can lead to more than n useful steps. Recursively updated residuals can drift from explicitly recomputed residuals, so a trustworthy implementation checks a scaled true residual when needed. No single raw tolerance suits every unit system or right-hand-side magnitude. An energy-error bound, a residual threshold, and a task-level accuracy requirement are related but distinct stopping criteria.

∥ek∥A∥e0∥A≤2(κ2(A)−1κ2(A)+1)k,∥e∥A=(eTAe)1/2\frac{\lVert e_k\rVert_A}{\lVert e_0\rVert_A}\le2\left(\frac{\sqrt{\kappa_2(A)}-1}{\sqrt{\kappa_2(A)}+1}\right)^k,\qquad \lVert e\rVert_A=(e^{\mathsf T}Ae)^{1/2}
For exact-arithmetic CG with real symmetric positive definite A, this bounds the energy error for k≥1; a zero initial error is handled as already solved.↔ Scroll wide equations horizontally.

Preconditioning changes the metric and must preserve the needed structure

For a symmetric positive definite preconditioner M, the conceptual symmetric transformed matrix is M to the negative one-half times A times M to the negative one-half. It remains positive definite. Preconditioned CG can implement the equivalent process using solves with M, without explicitly forming a square root or an inverse. The relevant condition number for the standard bound is that of the symmetric transformed matrix. The generally nonsymmetric-looking product M inverse A should not be handed to ordinary Euclidean CG without accounting for the corresponding metric.

A good preconditioner reduces iteration cost overall, not merely the number of iterations. Choosing M=A makes the transformed matrix the identity, but applying M inverse already solves the original problem and may defeat the purpose. Diagonal scaling is cheap and can remove simple scale disparity, while incomplete factorizations or multilevel methods may capture more structure at greater setup cost. Variable or nonsymmetric preconditioners require appropriate algorithm variants. Report setup, application, communication, and convergence together when deciding whether preconditioning actually improves a solve.

Two exact CG steps

Solve A=[[4,1],[1,3]], b=(1,2) by CG from x₀=(0,0).

  1. Start with r₀=p₀=(1,2). Ap₀=(6,7), so α₀=5/20=1/4. The first iterate is (1/4,1/2), and r₁=(−1/2,1/4).

  2. Since ‖r₁‖²=5/16, β₀=(5/16)/5=1/16. The next direction is p₁=(−7/16,3/8). Its matrix image is (−11/8,11/16), giving p₁ᵀAp₁=55/64.

  3. Thus α₁=(5/16)/(55/64)=4/11. Updating gives x₂=(1/11,7/11), whose matrix image is exactly (1,2). The residual is zero and the iteration stops.

The result

CG reaches the exact solution in two steps for this two-dimensional positive definite problem. Its short recurrence used both residual orthogonality and conjugate directions.

Explore the model

Interactive lab

Interactive lab · matrix

Read the condition entering an SPD bound

Reset, set a=0.25 and b=0. The selected matrix is symmetric positive definite with eigenvalues and singular values 0.25 and 1; predict κ₂=4 and CG bound factor (2−1)/(2+1)=1/3. Compare a fresh run using Reset, a=1, b=0, predicting identity geometry. The instrument does not run CG, and finite-dimensional exact termination can beat the displayed analytical bound.

Read the condition entering an SPD boundThe selected matrix is A = [[a,b],[0,1]]. Playback interpolates geometry between the identity and A; readouts always describe A. Its determinant is a and its singular values come from AᵀA. Positive a makes every supported matrix invertible. This two-dimensional family is not a general eigensolver or a learned network. Current readings: Area scale · det A: 1.4; Singular values · σmax, σmin: 1.597, 0.876; Condition number · κ₂(A): 1.823. All parameters are adjustable with the labeled controls below.Matrix A with first row 1.4, 0.6 and second row zero, one; display interpolates between identity and A while final determinant remains 1.4.−4−2024−2−1012x · equal geometric scaleyA = [ 1.4 0.6 ; 0 1 ]Display blend: 0% · final values below
Interpolated geometryOriginal unit squareSelected final transform
Area scale · det A
1.4
Singular values · σmax, σmin
1.597, 0.876
Condition number · κ₂(A)
1.823
t = 0 s

The selected matrix is A = [[a,b],[0,1]]. Playback interpolates geometry between the identity and A; readouts always describe A. Its determinant is a and its singular values come from AᵀA. Positive a makes every supported matrix invertible. This two-dimensional family is not a general eigensolver or a learned network. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.

Look forThe relevant positive spectrum controls an energy-norm worst-case estimate, not every observed residual curve.

Check your understanding

Which assumptions support the standard real conjugate-gradient energy-minimization guarantee?

Try it yourself

For A=diag(1,100) and M=diag(1,25), find the symmetric preconditioned matrix, its condition number, and the k=2 energy-bound factor. Compare that bound with exact two-dimensional termination.

Take a moment to make a prediction or work it out on paper. Open a hint when you need one.

Give me a hint

Use M⁻¹/²=diag(1,1/5), then apply the bound using the transformed eigenvalues.

Compare with the solution

The transformed matrix is diag(1,4), so its condition number is 4 rather than 100. The bound at k=2 is 2(1/3)²=2/9 times the initial energy error, interpreted in the corresponding transformed formulation. Exact-arithmetic CG actually terminates by two steps in this two-dimensional system, so the true final error is zero. A valid worst-case bound need not be sharp, and fewer iterations do not by themselves account for preconditioner cost.

Take it with you

  • CG uses positive-definite energy geometry rather than arbitrary residual minimization.
  • Condition-number bounds are worst-case estimates and finite precision changes exact termination properties.
  • A useful preconditioner must preserve required structure and improve total solve cost.

Read further

Original sources and deeper explanations to follow at your own pace.

Optional progress, saved in this browser when available. Revisit any lesson at any time.

Lesson not marked complete.