How to use this calculator
Solve a small dense symmetric positive-definite system using conjugate directions and inspect the remaining equation residual.
- Enter Matrix entries, row-major, Right-hand side, Initial solution, Maximum iterations. Match the units shown beside each field and review the result together with the assumptions below.
- Read the worked example below to check the expected input format and result.
- Compare another scenario by changing one input at a time. Use Reset to return to the starting values.
Symmetric positive definite conjugate gradient solve explained
Enter the symmetric coefficient matrix row by row and provide one right-hand-side value for each equation. The conjugate-gradient method requires a symmetric positive-definite matrix and reports the solved vector with its remaining residual.
A numerical walkthrough
Matrix entries, row-major = [4, 1, 0, 1, 3, 1, 0, 1, 2]; Right-hand side = [1, 2, 3]; Initial solution = [0, 0, 0]; Maximum iterations = 10.
- First solution component: 0.222222
- Residual two norm: 2.22044605e-16
- Iterations used: 3
- Complete solution vector: 0.222222222222, 0.111111111111, 1.44444444444 component order
The default three-unknown system is solved from zero; in exact arithmetic conjugate gradients needs at most three steps.
The model behind the numbers
α=rᵀr/(pᵀAp), x←x+αp, rnew=r−αAp, p←rnew+(rnewᵀrnew/rᵀr)p.
The matrix is checked for symmetry and positive definiteness before iteration. The iteration count is a cap; a numerically zero residual stops the solve.
What to enter
a— Matrix entries, row-major- Square matrix, entered row by row; 2–10 rows are supported. Use comma-separated values in the stated order.
b— Right-hand side- One equation right-hand side per matrix row. Use comma-separated values in the stated order.
x— Initial solution- Starting unknown vector. Use comma-separated values in the stated order.
steps— Maximum iterations- Iteration cap; exact zero residual stops earlier. Enter a whole number.
Interpreting the result
Dense educational implementation for up to 10 unknowns, without preconditioning. Loss of orthogonality in finite precision can require more than n steps.
Reading the outputs
First solution component and residual 2-norm are primary numerical outputs. An additional counter reports work performed. The complete solved vector or profile is also listed in the original component order, so no coordinate is hidden.
Frequently asked questions
Can I use a nonsymmetric matrix?
No. This implementation requires the SPD assumptions.
Why can more than n iterations be useful?
Finite precision can destroy exact conjugacy.
Does a small residual ensure small forward error?
Only when the matrix is sufficiently well conditioned.
How do I use the Symmetric positive definite conjugate gradient solve calculator?
Enter Matrix entries, row-major, Right-hand side, Initial solution, Maximum iterations. Match the units shown beside each field and review the result together with the assumptions below.
What is a worked example of Symmetric positive definite conjugate gradient solve?
Matrix entries, row-major = [4, 1, 0, 1, 3, 1, 0, 1, 2]; Right-hand side = [1, 2, 3]; Initial solution = [0, 0, 0]; Maximum iterations = 10. First solution component: 0.222222 Residual two norm: 2.22044605e-16 Iterations used: 3 Complete solution vector: 0.222222222222, 0.111111111111, 1.44444444444 component order The default three-unknown system is solved from zero; in exact arithmetic conjugate gradients needs at most three steps.
Background or definition reference: NIST DLMF numerical methods.
Read our calculation methodology.