Exercise: Jacobi and Gauss-Seidel compared
Solving a 4×4 system with Jacobi and with Gauss-Seidel from x⁰=0, comparing how many iterations each needs for the same tolerance.
The system and its solution
System (strictly diagonally dominant, so both converge), with exact solution x*=[1,2,−1,1] and initial guess x⁰=[0,0,0,0]:
| Component | Jacobi (k=10) | Gauss-Seidel (k=5) | Exact |
|---|---|---|---|
| x₁ | 0.9997 | 1.0001 | 1 |
| x₂ | 2.0004 | 2.0000 | 2 |
| x₃ | -1.0004 | -1.0000 | -1 |
| x₄ | 1.0006 | 1.0000 | 1 |