For this section, we must assume A is symmetric, positive-definite.
The solution of Ax=b is also the minimum of
.
The idea of CG is to iterate
where
are chosen so that
. A set of non-zero vectors
is
called A-conjugate if
. A-conjugate vectors are
also linearly independent. Starting with a zero
initial guess for the solution,
the iteration amounts to
. That is,
the successive iterates are linear combinations of the
vectors.
Thus the minimization will take at most N iterations.
Specifically, the steps are
Note that you never have to enter the matrix entry-by-entry. Rather, you need to supply a routine that multiplies a given vector by a matrix.
For ill-conditioned matrices, even CG is slow. To speed-up the convergence, one pre-conditions the system. That is, one multiplies on the left by a pre-conditioning matrix, transforming the system.
Choosing Q so that B is well conditioned will help enormously.
If B is close to the identity, then
,
so the Cholesky factorization of A can be useful.
There are efficient ways of using preconditioners. In particular, you
do not have to explicitly multiply matrices. Rather the
CG algorithm includes another step in which an intermediate vector is
multiplied by the preconditioner.
CG works only if A is symmetric, positive definite. What to do if
we have a matrix that does not satisfy these conditions?
Well, the matrix
is symmetric, and positive definite
(all bets are off if A has a zero eigenvalue). You can try to use
CG on this product matrix, recognizing
. This is the basis of teh
conjugate gradient squared method. The drawback is that
the condition number of
is the square of the condition number of A.
Another variant of this idea is the bi-conjugate gradient method.