For a large system with mostly zero entries, elimination's $\frac{2}{3}n^{3}$ flops (see The Cost of Elimination) can be far too many. An iterative method starts from a guess and improves it using only cheap products with $A$. Jacobi's method is the simplest, and it is a Fixed-Point Iteration in disguise.
Solve equation $i$ for $x_i$, and put the previous values on the right: $$x_i^{(k+1)} = \frac{1}{a_{ii}}\left(b_i - \sum_{j \ne i}a_{ij}x_j^{(k)}\right).$$ In matrix form, with $A = D + L + U$ (diagonal, strictly lower, strictly upper parts), $\mathbf{x}^{(k+1)} = D^{-1}\big(\mathbf{b} - (L + U)\mathbf{x}^{(k)}\big)$.
Key idea
Why it works
Worked example: Three sweeps
- Iteration: $x \leftarrow \frac{6 - y}{4}$, $y \leftarrow \frac{9 - 2x}{5}$, both from the old values.
- Sweep 1: $(\frac{6}{4}, \frac{9}{5}) = (1.5, 1.8)$.
- Sweep 2: $(\frac{6 - 1.8}{4}, \frac{9 - 3}{5}) = (1.05, 1.2)$.
- Sweep 3: $(\frac{6 - 1.2}{4}, \frac{9 - 2.1}{5}) = (1.2, 1.38)$, closing in on the solution from both sides.
Answer: $(1.2, 1.38)$ after three sweeps
Worked example: The order of the equations matters
- Iteration: $x \leftarrow \frac{9 - 5y}{2}$, $y \leftarrow 6 - 4x$. Neither row is diagonally dominant.
- From $(0, 0)$: $(4.5, 6)$, then $(-10.5, -12)$, then $(34.5, 48), \ldots$ It diverges.
- Here $\rho(T) = \sqrt{\frac{5}{2} \cdot 4} = \sqrt{10} > 1$. Swapping the equations gives $\rho = \sqrt{\frac{1}{4} \cdot \frac{2}{5}} = \sqrt{0.1} \approx 0.32$.
Answer: it diverges; swap the equations
One sweep costs about two flops per nonzero entry of $A$, so for a sparse matrix with a few nonzeros per row a sweep is cheap, far cheaper than elimination. In practice the iteration stops when the residual $\lVert\mathbf{b} - A\mathbf{x}^{(k)}\rVert$ is small compared with $\lVert\mathbf{b}\rVert$, or when successive iterates barely change. Diagonal dominance is enough for convergence but not necessary; what matters exactly is whether $\rho(T) < 1$.
Common mistake