1. Linear systems: direct and iterative methods¶
A linear system \(Ax = b\) has an \(n \times n\) matrix \(A\), a right-hand side \(b\) and an unknown vector \(x\). Linear systems are everywhere: currents in an electrical network, forces in a structure, and above all the large systems that appear when a differential equation is discretised (for example the temperature at every point of a grid).
Direct methods¶
Gaussian elimination (or an LU factorisation) solves \(Ax = b\) in a fixed number of steps, about \(\tfrac23 n^3\) arithmetic operations for a dense matrix. For small and moderate dense systems, a direct solver is often a suitable baseline; the time depends on the computer and implementation.
Iterative methods¶
For the systems that come from differential equations, \(n\) can be in the millions, and almost every entry of \(A\) is zero (the matrix is sparse). Elimination can fill in zeros and use substantial memory, although sparse direct solvers remain useful for many problems. An iterative method starts from a guess \(x^{(0)}\) and improves it, one sweep at a time:
where each sweep costs about as much as one multiplication by \(A\). The questions are: does the sequence converge, and how many sweeps does it need? This unit answers both, with evidence.
The supplied matrices and student functions use dense NumPy arrays for teaching. They are not optimised large-scale sparse solvers. Use the small test sizes in the unit; an efficient sparse implementation is further work.
The splitting \(A = D - L - U\)¶
All three methods in this unit use the same splitting of \(A\): \(D\) is the diagonal of \(A\), \(-L\) is the part strictly below the diagonal, and \(-U\) the part strictly above. The methods need every diagonal entry \(a_{ii}\) to be nonzero.
The test systems¶
System |
Description |
Size |
Used for |
|---|---|---|---|
L1 |
Burden and Faires’ 4 × 4 example (solution \((1, 2, -1, 1)\)) |
4 |
gate G1 |
L2 |
A non-symmetric, diagonally dominant 5 × 5 system |
5 |
gates G1, G2 |
L3 |
The 1D Poisson model problem: \(2\) on the diagonal, \(-1\) next to it |
6 to 40 |
gates G1, G3; results R1 to R3, R5 |
L4 |
The 2D Poisson problem on a 6 × 6 grid |
36 |
gate G4 |
L5 |
Symmetric positive definite, not diagonally dominant |
3 |
result R4 |
L6 |
The classical counterexample |
3 |
result R4 |
Every system has a known exact solution, so the error can always be measured.