Statistical Methods

Audit Residual and Convergence in a Conjugate-Gradient Solve

Define the task

Conjugate gradient is designed for a symmetric positive-definite system, with the Hermitian counterpart for complex arithmetic. Before using it, establish why the operator meets those requirements and choose a suitable preconditioner if needed. A returned vector alone is not evidence of successful convergence. Record the initial guess, stopping criteria, iteration limit, solver status and numerical precision. An inappropriate matrix can make an apparently convenient iterative method unreliable.

Carry out the check

Recompute b−Ax using the original operator and compare its norm with the documented threshold max(rtol times norm(b), atol). Read the status code and distinguish a successful stop from reaching an iteration limit. A small residual need not imply small solution error when conditioning is poor. Document any preconditioner separately from the original system, and do not silently loosen tolerances until a failure disappears. Use a small independently solved system before applying the solver at scale.

Worked hypothetical example

For hypothetical A=diag(2,4), b=(2,8) and proposed x=(1,1.9), the residual is (0,0.4), with norm 0.4. At rtol=0.01 and atol=0, the threshold is 0.01×sqrt(68), approximately 0.08246; this proposal fails that check. The exact solution is (1,2). This is residual arithmetic, not a claimed solver run. Preserve both the stopping report and independently recomputed residual in the analysis record.

Method checked 21 November 2026 against Primary method documentation: cg.

Download the iterative solve acceptance worksheet.

Related reading

Reading path: Analyze data. Guide 191 of 192. Choose any guide to suit your project.

Statistical Methods

Check an Analytic Gradient Before Trusting an Optimizer

Practical steps and a hypothetical example: Audit a supplied analytic gradient at several parameter values.

Statistical Methods

Audit Residual Contributions to a Huber Loss

Practical steps and a hypothetical example: Audit the contribution of large residuals to a prespecified robust loss.

Browse this reading pathTools for this stageGuides and downloads for this stage