Solve system of linear equations — preconditioned conjugate gradients method

attempts to solve the system of linear equations `x`

= pcg(`A`

,`b`

)`A*x = b`

for
`x`

using the Preconditioned Conjugate Gradients Method. When the attempt is
successful, `pcg`

displays a message to confirm convergence. If
`pcg`

fails to converge after the maximum number of iterations or halts
for any reason, it displays a diagnostic message that includes the relative residual
`norm(b-A*x)/norm(b)`

and the iteration number at which the method
stopped.

specifies a preconditioner matrix `x`

= pcg(`A`

,`b`

,`tol`

,`maxit`

,`M`

)`M`

and computes `x`

by
effectively solving the system $${H}^{-1}A\text{\hspace{0.17em}}{H}^{-T}y={H}^{-1}b$$ for *y*, where $$y={H}^{T}x$$ and $$H={M}^{1/2}={\left({M}_{1}{M}_{2}\right)}^{1/2}$$. Using a preconditioner matrix can improve the numerical properties of the
problem and the efficiency of the calculation.

`[`

returns a flag that specifies whether the algorithm successfully converged. When
`x`

,`flag`

] = pcg(___)`flag = 0`

, convergence was successful. You can use this output syntax
with any of the previous input argument combinations. When you specify the
`flag`

output, `pcg`

does not display any diagnostic
messages.

Convergence of most iterative methods depends on the condition number of the coefficient matrix,

`cond(A)`

. You can use`equilibrate`

to improve the condition number of`A`

, and on its own this makes it easier for most iterative solvers to converge. However, using`equilibrate`

also leads to better quality preconditioner matrices when you subsequently factor the equilibrated matrix`B = R*P*A*C`

.You can use matrix reordering functions such as

`dissect`

and`symrcm`

to permute the rows and columns of the coefficient matrix and minimize the number of nonzeros when the coefficient matrix is factored to generate a preconditioner. This can reduce the memory and time required to subsequently solve the preconditioned linear system.

[1] Barrett, R., M. Berry, T. F. Chan, et al., *Templates
for the Solution of Linear Systems: Building Blocks for Iterative Methods*, SIAM,
Philadelphia, 1994.