In mathematics, the conjugate gradient method is an algorithm for the numerical solution of particular systems of linear equations, namely those whose matrix is positive-semidefinite. The conjugate gradient method is often implemented as an iterative algorithm, applicable to sparse systems that are too large to be handled by a direct implementation or other direct methods such as the Cholesky decomposition. Large sparse systems often arise when numerically solving partial differential equations or optimization problems. The conjugate gradient method can also be used to solve unconstrained optimization problems such as energy minimization. It is commonly attributed to Magnus Hestenes and Eduard Stiefel, who programmed it on the Z4, and extensively researched it. The biconjugate gradient method provides a generalization to non-symmetric matrices. Various nonlinear conjugate gradient methods seek minima of nonlinear optimization problems.
Description of the problem addressed by conjugate gradients Suppose we want to solve the system of linear equations
𝐀𝐱=𝐛 for the vector 𝐱, where the known n×n matrix 𝐀 is symmetric (i.e., 𝐀𝖳=𝐀), positive-definite (i.e. 𝐱𝖳𝐀𝐱>0 for all non-zero vectors 𝐱 in ℝn), and real, and 𝐛 is known as well. We denote the unique solution of this system by 𝐱∗.
Derivation as a direct method
The conjugate gradient method can be derived from several different perspectives, including specialization of the conjugate direction method for optimization, and variation of the Arnoldi/Lanczos iteration for eigenvalue problems. Despite differences in their approaches, these derivations share a common topic—proving the orthogonality of the residuals and conjugacy of the search directions. These two properties are crucial to developing the well-known succinct formulation of the method. We say that two non-zero vectors 𝐮 and 𝐯 are conjugate (with respect to 𝐀) if
𝐮𝖳𝐀𝐯=0. Since 𝐀 is symmetric and positive-definite, the left-hand side defines an inner product
𝐮𝖳𝐀𝐯=⟨𝐮,𝐯⟩𝐀:=⟨𝐀𝐮,𝐯⟩=⟨𝐮,𝐀𝖳𝐯⟩=⟨𝐮,𝐀𝐯⟩. Two vectors are conjugate if and only if they are orthogonal with respect to this inner product. Being conjugate is a symmetric relation: if 𝐮 is conjugate to 𝐯, then 𝐯 is conjugate to 𝐮. Suppose that
P={𝐩1,…,𝐩n} is a set of n mutually conjugate vectors with respect to 𝐀, i.e. 𝐩i𝖳𝐀𝐩j=0 for all i≠j. Then P forms a basis for ℝn, and we may express the solution 𝐱∗ of 𝐀𝐱=𝐛 in this basis:
𝐱∗=∑i=1nαi𝐩i⇒𝐀𝐱∗=∑i=1nαi𝐀𝐩i. Left-multiplying the problem 𝐀𝐱=𝐛 with the vector 𝐩k𝖳 yields
𝐩k𝖳𝐛=𝐩k𝖳𝐀𝐱∗=∑i=1nαi𝐩k𝖳𝐀𝐩i=∑i=1nαi⟨𝐩k,𝐩i⟩𝐀=αk⟨𝐩k,𝐩k⟩𝐀 and so
αk=⟨𝐩k,𝐛⟩⟨𝐩k,𝐩k⟩𝐀. This gives the following method for solving the equation 𝐀𝐱=𝐛: find a sequence of n conjugate directions, and then compute the coefficients αk.
As an iterative method If we choose the conjugate vectors 𝐩k carefully, then we may not need all of them to obtain a good approximation to the solution 𝐱∗. So, we want to regard the conjugate gradient method as an iterative method. This also allows us to approximately solve systems where n is so large that the direct method would take too much time. We denote the initial guess for 𝐱∗ by 𝐱0 (we can assume without loss of generality that 𝐱0=𝟎, otherwise consider the system 𝐀𝐳=𝐛−𝐀𝐱0 instead). Starting with 𝐱0 we search for the solution and in each iteration we need a metric to tell us whether we are closer to the solution 𝐱∗ (that is unknown to us). This metric comes from the fact that the solution 𝐱∗ is also the unique minimizer of the following quadratic function
f(𝐱)=12𝐱𝖳𝐀𝐱−𝐱𝖳𝐛,𝐱∈ℝn. The existence of a unique minimizer is apparent as its Hessian matrix of second derivatives is symmetric positive-definite
𝐇(f(𝐱))=𝐀, and that the minimizer (use Df(𝐱)=0) solves the initial problem follows from its first derivative
∇f(𝐱)=𝐀𝐱−𝐛. This suggests taking the first basis vector 𝐩0 to be the negative of the gradient of f at 𝐱=𝐱0. The gradient of f equals 𝐀𝐱−𝐛. Starting with an initial guess 𝐱0, this means we take 𝐩0=𝐛−𝐀𝐱0. The other vectors in the basis will be conjugate to the gradient, hence the name conjugate gradient method. Note that 𝐩0 is also the residual provided by this initial step of the algorithm. Let 𝐫k be the residual at the kth step:
𝐫k=𝐛−𝐀𝐱k. As observed above, 𝐫k is the negative gradient of f at 𝐱k, so the gradient descent method would require to move in the direction rk. Here, however, we insist that the directions 𝐩k must be conjugate to each other. A practical way to enforce this is by requiring that the next search direction be built out of the current residual and all previous search directions. The conjugation constraint is an orthonormal-type constraint and hence the algorithm can be viewed as an example of Gram-Schmidt orthonormalization. This gives the following expression:
𝐩k=𝐫k−∑i<k𝐫k𝖳𝐀𝐩i𝐩i𝖳𝐀𝐩i𝐩i (see the picture at the top of the article for the effect of the conjugacy constraint on convergence). Following this direction, the next optimal location is given by
𝐱k+1=𝐱k+αk𝐩k with
αk=𝐩k𝖳(𝐛−𝐀𝐱k)𝐩k𝖳𝐀𝐩k=𝐩k𝖳𝐫k𝐩k𝖳𝐀𝐩k, where the last equality follows from the definition of 𝐫k . The expression for αk can be derived if one substitutes the expression for xk+1 into f and minimizing it with respect to αk
f(𝐱k+1)=f(𝐱k+αk𝐩k)=:g(αk)g′(αk)=!0⇒αk=𝐩k𝖳(𝐛−𝐀𝐱k)𝐩k𝖳𝐀𝐩k.
… excerpt ends here. Continue reading the full article.

