Linear system
You have one of these when every rule in the model is linear in the unknowns, the unknowns are a finite list, and nothing changes with time.
Linear system, not a saddle point. The unknowns here are the only ones. A saddle point adds a second unknown for every rule that has to hold everywhere.
What you are modelling
A balance. The forces at a joint add to zero, the currents into a node add to zero, the flow through a face equals the flow out of it. Or a fit: the model is a sum of known shapes, and you want the amounts of each.
The system itself is linear, so no non-linear iteration is needed. The work is done once the rows are written, and the difficulty has moved into the matrix — where a large sparse system may still call for an iterative solver.
The model you write down
Each row is one rule, each column is one unknown, and is what the rules have to equal. The physics of the problem has already finished its job by the time you have .
What it becomes on a computer
Worked number. The system , has the solution , , and substituting it leaves a residual of zero.
A matrix, and a choice between two families. The choice is made by the properties of the matrix, not by the subject the matrix came from:
- Dense and small. Factorise it. The cost is cubic in the number of unknowns, and for a few thousand that is the end of the story.
- Sparse and large. Factorising fills in the zeros and runs out of memory,
so iterate instead — and the iteration count is decided by conditioning, not
by size. The
double-wishboneexample in this collection is the small version of that: it solves 21 equations, and its Jacobian has 441 entries, of which 161 are not zero. At that sparsity the sparsity is the method rather than a detail of it, and the generated kernel touches only the non-zeros. What a kernel is is the page that explains the generated solver the figures in this collection run. - Symmetric positive definite. Conjugate gradients works, and fails on anything else.
- Symmetric indefinite. A different Krylov method is needed, and the reason is the saddle point page.
- Rectangular. More equations than unknowns is a least-squares problem, and the answer is a projection rather than a solution.
Both families can be helped by the same idea. A preconditioner is a cheaper approximation to . The iteration solves , an easier problem with the same answer, and then corrects it; the price is that has to be built and applied.
A linear system is often one step inside a non-linear solve. Maths Applied
§1.3's three distance rules are
non-linear, and Gauss–Newton iterates them; each step solves the linear system
on this page. The rules at that step are linear, and the outer model is a root
problem or an optimisation. That is the distinction the
class is a choice page makes: the class
belongs to the writing, and the writing can be one step of a larger model.
Conjugate gradients is the method for the symmetric positive-definite case, and the residual is its progress bar. The figure solves the one-dimensional Poisson system from the elliptic page. The residual reaches the floor in at most iterations. That is exactness in exact arithmetic, not a tuning choice.
The signature
The answer comes from a matrix, and the matrix's properties decide the method. Two consequences follow, and both surprise people:
- Scale is not difficulty. A million-unknown sparse system with good conditioning solves in seconds; a hundred-unknown matrix with a condition number of has lost twelve digits and cannot give you an answer you can trust.
- Reordering the rows changes the answer. In exact arithmetic it cannot. In floating point, a different pivot order changes the rounding, and an ill-conditioned matrix turns that into a different last digit or a different answer.
Flags that matter here
- Conditioning. The one flag that matters most, and the one nobody checks. It is the number of digits you lose.
- Symmetry and definiteness. They decide which methods are available, and a method used outside its class does not merely run slowly; it returns nonsense.
- Sparsity and fill-in. A sparse matrix that factorises into a dense one is a memory problem wearing a maths problem's clothes.
- Redundant rows. Two rows that say the same thing give either no solution or infinitely many, and a solver that does not notice returns one of them.
Techniques
Every method named here is in Methods, A to Z, with its price and what it will not do.
Start from the model you have. Each row is a property of the model in front of you, the methods that fit it, and what the fit costs. The method-keyed table below is the same list sorted by name.
| what your model is | the methods that fit | the price |
|---|---|---|
| dense and a few thousand | Dense LU, with pivoting, QR, SVD, iterative refinement | cubic, once |
| sparse and large | Sparse direct (multifrontal), GMRES, BiCGSTAB, Preconditioners (ILU, AMG, Jacobi) | the iteration count is the flag |
| symmetric positive definite | Cholesky, conjugate gradients, multigrid | fails on anything else |
| symmetric indefinite | MINRES | a different Krylov method is needed |
| a least-squares or rank-deficient problem | QR, SVD, normal equations | squaring the condition number |
| technique | what it does | when it wins | when it is the wrong tool |
|---|---|---|---|
| Dense LU, with pivoting | Factorises a general matrix | A few thousand unknowns, one solve or many right-hand sides | Large sparse problems |
| Cholesky | Factorises a symmetric positive definite matrix | The matrix is SPD, and you want half the work of LU | Any non-symmetric or indefinite matrix |
| QR, SVD | Factorises a rectangular matrix | Least squares, rank deficiency, a diagnostic of conditioning | Very large sparse problems |
| Normal equations | Squares the system and uses Cholesky | Overdetermined and well conditioned, and you want speed | Anything else: it squares the condition number |
| Sparse direct (multifrontal) | Factorises with a fill-reducing ordering | Two dimensions; repeated solves with the same matrix | Three dimensions, where fill-in wins |
| Conjugate gradients | Krylov method for SPD systems | Large, sparse, symmetric positive definite | Indefinite or non-symmetric matrices |
| GMRES, BiCGSTAB | Krylov methods for general matrices | Non-symmetric, sparse | Memory: GMRES stores every vector unless restarted |
| MINRES | Krylov method for symmetric indefinite systems | Symmetry with indefiniteness | Non-symmetric matrices |
| Preconditioners (ILU, AMG, Jacobi) | Changes the system the iteration sees | Almost always, in practice | You have not measured the iteration count |
| Multigrid | Solves on a hierarchy of meshes | The matrix came from an elliptic problem | A matrix from anywhere else |
| Iterative refinement | Corrects a solve with its own residual | Ill-conditioned, and you want every digit | The factorisation is expensive, and a second solve is not affordable |
Systems that live here
- The stiffness matrix of a structural analysis: the displacement of every node.
- Nodal analysis of a circuit: the voltage at every node.
- Any steady discretisation, once the equations are assembled: see Elliptic.
- The
double-wishboneexample's Jacobian: 21 equations, 161 of 441 entries non-zero. - A least-squares fit: a tyre model, a calibration curve, a camera model.
- Network flows, and the stationary vector of a link matrix.
- Spline and surface fitting, where the unknowns are the control points.
What goes wrong
| symptom | cause | fix |
|---|---|---|
| The residual is tiny and the answer is wrong | The matrix is ill-conditioned; a small residual says little | Check the condition number; scale the unknowns |
| The factorisation runs out of memory | Fill-in: a sparse matrix with a dense factor | A fill-reducing ordering, or an iterative method |
| Conjugate gradients stalls or returns nonsense | The matrix is not symmetric positive definite | Check symmetry; use GMRES or MINRES |
| The answer changes when the rows are reordered | Rounding, amplified by conditioning | Fix a pivot ordering, and report the conditioning |
| The solver reports no solution, or infinitely many | Redundant or contradictory rows | A rank-revealing factorisation, and fix the model |
| The iterative method needs thousands of steps | No preconditioner, or a poor one | Precondition; measure the count before and after |
Used in this collection
- A-level Mathematics · §11.4 Scatter diagrams, regression lines and correlation
- Maths Applied · §1.3 Two legs, one contradiction
- Maths Applied · §1.4 The redundancy was ours
Read next
- The same corner, five ways — this class, worked on one mechanism with the numbers beside it.
- One matrix, two errors — the working under this class: a condition number and the two errors, on one matrix.
- Root finding — the same question when a rule bends with the answer.
- Elliptic — where most of these matrices come from.
- Saddle point — a symmetric matrix that is not positive definite, and why that changes the method.
- When it goes wrong — the symptom table for every class.
Back to the map: the nine kinds puts this class among the other eight.