- Home
- Articles
- Vectors & Linear Algebra
- Jacobi vs Gauss–Seidel
// Article · Numerical methods
Solving Linear Systems Numerically: Gauss, LU, Jacobi or Gauss–Seidel — Which Should You Use?
Circuit simulators, structural software and heat models must solve with thousands to millions of unknowns, where classroom methods are not enough. This article compares all the main methods at a glance: how each works, how fast it is, and when to choose it.
- Direct methods (Gauss, LU, Cholesky, Thomas) finish in a fixed number of steps; best for dense, moderate-size systems; always pivot
- Iterative methods (Jacobi, Gauss–Seidel, SOR) refine a guess each sweep; best for large sparse systems
- Gauss–Seidel is usually about twice as fast as Jacobi; SOR with a good is several times faster still
- Before trusting an answer, check the condition number : about digits may be lost
The big picture: direct versus iterative
Cramer's rule is not on this map because its cost grows factorially: a 20-unknown system needs about multiplications against about 2,700 for Gaussian elimination (see the Cramer's rule article).
Direct methods: Gauss, LU, Cholesky and Thomas
Gaussian elimination zeroes everything below the diagonal and then back-substitutes, using about flops. The crucial detail is partial pivoting: use the largest entry in the column as the pivot. On a machine keeping 3 significant digits:
The multiplier makes round to , wiping out the information in the first equation. Try other digit counts in the pivoting lab (in Thai).
- LU factorisation is Gaussian elimination that keeps the multipliers in . Factor once, then each new costs only — ideal for a circuit whose sources change but whose structure does not.
- Cholesky is for symmetric positive definite matrices such as the conductance matrix of a resistor network: twice as fast as LU and no pivoting.
- Thomas handles tridiagonal matrices (heat rods, ladder networks) in ; a rod held at 100 °C and 0 °C with 4 interior nodes gives °C.
Iterative methods: Jacobi versus Gauss–Seidel
Both solve equation for using current estimates of the other unknowns; the only difference is whether they use the “old” or the “new” values.
The system has solution ; start from :
| Sweep | Jacobi | Gauss–Seidel |
|---|---|---|
| 1 | (1.750, 3.375, 3.000) | (1.750, 3.750, 2.950) |
| 2 | (1.844, 3.875, 3.025) | (1.950, 3.969, 2.986) |
| 3 | (1.963, 3.925, 2.963) | (1.996, 3.996, 2.999) |
When they converge, and how SOR speeds things up
- Strict diagonal dominance in every row → guaranteed convergence. If it fails, try reordering the equations first.
- The exact condition is a spectral radius , and about sweeps are needed to gain digits.
- SOR overshoots the Gauss–Seidel value by a factor . A 10-unknown heat rod needs about 334 sweeps (Jacobi) and 167 (Gauss–Seidel), but SOR with needs only about 24.
Compare all three side by side in the Jacobi · Gauss–Seidel · SOR simulator and watch heat spread through a plate sweep by sweep in the heat-plate lab (both in Thai).
The condition number: how far can you trust the answer?
When equations are nearly parallel, a tiny change in the data moves the answer a lot. has solution , but changing the right-hand side to gives . Its condition number means 4–5 digits may be lost.
Decision table
| Your system | Use |
|---|---|
| 2–3 unknowns by hand | Cramer's rule or row reduction |
| Dense, moderate size, several | LU with pivoting (numpy.linalg.solve, MATLAB A\b) |
| Symmetric positive definite | Cholesky |
| Tridiagonal | Thomas |
| Large, sparse, diagonally dominant | Gauss–Seidel or SOR |
| Very large, symmetric positive definite | Conjugate gradient + preconditioner |
Continue in the library (in Thai)
- Numerical solution of linear systems in full: formulas N1–N26, examples and five simulators
- Systems of linear equations and Gaussian elimination by hand
- Eigenvalues: where the spectral radius comes from
- Numerical-methods exam problems with solutions
- Article: the rank of a matrix and the existence of solutions
Frequently asked questions
What is the difference between Jacobi and Gauss–Seidel?
Jacobi computes every unknown of the new sweep from the previous sweep's values, while Gauss–Seidel uses each newly computed value immediately within the same sweep. Gauss–Seidel therefore usually converges about twice as fast and needs less memory, while Jacobi is easier to parallelise.
When should an iterative method be used instead of LU?
When the system is very large and the matrix is mostly zeros (sparse), as in heat, electric-field or finite-element simulations with tens of thousands to millions of unknowns. Iterative methods need no full matrix storage and cause no fill-in. For dense systems of moderate size, use LU with partial pivoting.
Why pivot in Gaussian elimination?
Choosing the largest entry in the column as the pivot keeps every multiplier at most 1, so round-off errors are not amplified. With a tiny pivot such as 0.0001, a machine that keeps 3 significant digits returns a completely wrong answer.
When does an iterative method converge?
If the matrix is strictly diagonally dominant, Jacobi and Gauss–Seidel are guaranteed to converge. The exact condition is that the spectral radius of the iteration matrix is less than 1, and the number of sweeps needed is roughly the number of digits wanted divided by −log₁₀ of the spectral radius.