Jacobi Method
The Jacobi method solves a linear system Ax = b by iteration. Solve each equation for its diagonal variable, plug the previous guess into the right side, and repeat. If A is strictly diagonally dominant, the Jacobi iterates converge to the solution from any starting guess.
Before this lesson: Partial Pivoting, Fixed-Point Iteration and Gaussian Elimination
The idea: turn the system into a fixed-point problem
Gaussian elimination is a direct method: it finishes in a fixed number of steps. For very large systems with mostly zero entries, such as the ones that come from heat flow or networks, elimination fills in the zeros and becomes slow. Iterative methods instead improve a guess again and again.
The Jacobi method rewrites equation i so that its diagonal variable xᵢ is alone on the left. The system becomes x = g(x), just like fixed-point iteration for one equation. Every new value uses only old values, so all n updates can be done at the same time.
The graph shows the Jacobi iterates for Example 1. Each new point moves part of the way toward the intersection of the two lines, and the steps shrink quickly.
Jacobi method formula
For equation i of an n × n system with aᵢᵢ ≠ 0, the Jacobi update is
x_i^{(k+1)} = \dfrac{1}{a_{ii}}\left(b_i - \sum_{j \ne i} a_{ij}\, x_j^{(k)}\right),\quad i = 1, 2, \ldots, nIn matrix form, split A = D + R, where D holds the diagonal entries and R holds everything else. Then
\mathbf{x}^{(k+1)} = D^{-1}\left(\mathbf{b} - R\,\mathbf{x}^{(k)}\right),\qquad T_J = -D^{-1}RWhen does the Jacobi method converge?
- Sufficient test: if A is strictly diagonally dominant (in every row, |aᵢᵢ| is greater than the sum of the absolute values of the other entries), Jacobi converges for every starting guess.
- Exact test: Jacobi converges for every starting guess if and only if the spectral radius ρ(T_J), the largest absolute value of an eigenvalue of T_J, is less than 1. The error shrinks by a factor of about ρ(T_J) per iteration.
- Stopping rule: stop when the largest change in any variable, ‖x⁽ᵏ⁺¹⁾ − x⁽ᵏ⁾‖∞, is below a chosen tolerance.
How to use the Jacobi method
- Check (or arrange) that the diagonal entries are nonzero, ideally strictly diagonally dominant.
- Solve equation i for xᵢ.
- Pick a starting guess, often x⁽⁰⁾ = 0.
- Compute every new xᵢ from the old values only.
- Repeat until the largest change is below the tolerance.
Jacobi method examples
Example 1: A 2 × 2 system
Use the Jacobi method on 4x + y = 9 and x + 5y = 7, starting at (0, 0). Do four iterations. The exact solution is (2, 1).
|4| \gt |1|,\quad |5| \gt |1|
The system is strictly diagonally dominant, so Jacobi converges.
x^{(k+1)} = \dfrac{9 - y^{(k)}}{4},\quad y^{(k+1)} = \dfrac{7 - x^{(k)}}{5}Solve each equation for its diagonal variable.
x^{(1)} = \dfrac{9 - 0}{4} = 2.25,\quad y^{(1)} = \dfrac{7 - 0}{5} = 1.4Iteration 1 uses (0, 0).
x^{(2)} = \dfrac{9 - 1.4}{4} = 1.9,\quad y^{(2)} = \dfrac{7 - 2.25}{5} = 0.95Iteration 2 uses (2.25, 1.4).
x^{(3)} = \dfrac{9 - 0.95}{4} = 2.0125,\quad y^{(3)} = \dfrac{7 - 1.9}{5} = 1.02Iteration 3 uses (1.9, 0.95).
x^{(4)} = \dfrac{9 - 1.02}{4} = 1.995,\quad y^{(4)} = \dfrac{7 - 2.0125}{5} = 0.9975Iteration 4 uses (2.0125, 1.02).
Answer: after four iterations, (x, y) = (1.995, 0.9975), within 0.005 of the solution (2, 1).
Example 2: A 3 × 3 system with an iteration table
Use the Jacobi method on the system below, starting at (0, 0, 0). The exact solution is (1, −1, 2).
\begin{aligned} 5x - y + z &= 8 \\ 2x + 8y - z &= -8 \\ -x + y + 4z &= 6 \end{aligned}|5| \gt 1 + 1,\quad |8| \gt 2 + 1,\quad |4| \gt 1 + 1
Check strict diagonal dominance row by row.
x = \dfrac{8 + y - z}{5},\quad y = \dfrac{-8 - 2x + z}{8},\quad z = \dfrac{6 + x - y}{4}Solve each equation for its diagonal variable.
x^{(1)} = \dfrac{8}{5} = 1.6,\quad y^{(1)} = \dfrac{-8}{8} = -1,\quad z^{(1)} = \dfrac{6}{4} = 1.5Iteration 1 uses (0, 0, 0).
x^{(2)} = \dfrac{8 + (-1) - 1.5}{5} = \dfrac{5.5}{5} = 1.1Iteration 2 uses (1.6, −1, 1.5).
y^{(2)} = \dfrac{-8 - 2(1.6) + 1.5}{8} = \dfrac{-9.7}{8} = -1.2125Use the old x = 1.6, not the new 1.1.
z^{(2)} = \dfrac{6 + 1.6 - (-1)}{4} = \dfrac{8.6}{4} = 2.15Use the old x and y.
x^{(3)} = \dfrac{8 + (-1.2125) - 2.15}{5} = \dfrac{4.6375}{5} = 0.9275Iteration 3 uses (1.1, −1.2125, 2.15).
y^{(3)} = \dfrac{-8 - 2(1.1) + 2.15}{8} = \dfrac{-8.05}{8} = -1.00625Old values only.
z^{(3)} = \dfrac{6 + 1.1 - (-1.2125)}{4} = \dfrac{8.3125}{4} = 2.078125Old values only.
Continuing the same way gives the table below (values rounded to 6 decimal places). The last column is the largest change from the previous row.
| k | x | y | z | Largest change |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | — |
| 1 | 1.6 | −1 | 1.5 | 1.6 |
| 2 | 1.1 | −1.2125 | 2.15 | 0.65 |
| 3 | 0.9275 | −1.00625 | 2.078125 | 0.20625 |
| 4 | 0.983125 | −0.972109 | 1.983438 | 0.094688 |
| 5 | 1.008891 | −0.997852 | 1.988809 | 0.025766 |
| 6 | 1.002668 | −1.003622 | 2.001686 | 0.012877 |
| 7 | 0.998939 | −1.000456 | 2.001572 | 0.003729 |
| 8 | 0.999594 | −0.999538 | 1.999849 | 0.001724 |
Answer: after 8 iterations the largest change is about 0.0017, and the iterate (0.999594, −0.999538, 1.999849) is within 0.0005 of (1, −1, 2).
Example 3: Reordering for diagonal dominance
The system x + 5y − z = 10, 4x + y + z = 7, x − y + 3z = 2 is not diagonally dominant as written, because the first equation has diagonal entry 1. Reorder it, then do two Jacobi iterations from (0, 0, 0).
4x + y + z = 7,\quad x + 5y - z = 10,\quad x - y + 3z = 2
Move the equation with the large x-coefficient to the top.
|4| \gt 1 + 1,\quad |5| \gt 1 + 1,\quad |3| \gt 1 + 1
Now every row is strictly diagonally dominant.
x = \dfrac{7 - y - z}{4},\quad y = \dfrac{10 - x + z}{5},\quad z = \dfrac{2 - x + y}{3}Solve for the diagonal variables.
x^{(1)} = 1.75,\quad y^{(1)} = 2,\quad z^{(1)} = \dfrac{2}{3} \approx 0.666667Iteration 1 uses (0, 0, 0).
x^{(2)} = \dfrac{7 - 2 - \tfrac{2}{3}}{4} = \dfrac{13/3}{4} = \dfrac{13}{12} \approx 1.083333Iteration 2 uses (1.75, 2, 2/3).
y^{(2)} = \dfrac{10 - 1.75 + \tfrac{2}{3}}{5} = \dfrac{107/12}{5} = \dfrac{107}{60} \approx 1.7833338.25 + 2/3 = 107/12 (see adding and subtracting fractions).
z^{(2)} = \dfrac{2 - 1.75 + 2}{3} = \dfrac{2.25}{3} = 0.75Old values only.
Answer: x⁽²⁾ ≈ (1.083333, 1.783333, 0.75). Reordering only changes the order of the equations, so the solution is still (1, 2, 1), and now convergence is guaranteed.
Example 4: When the Jacobi method diverges
Apply Jacobi to x + 2y = 3 and 3x + y = 4 (solution (1, 1)), then fix the problem.
x = 3 - 2y,\quad y = 4 - 3x
Jacobi formulas for the system as written.
(0, 0) \to (3, 4) \to (-5, -5) \to (13, 19) \to (-35, -35)
For example, x = 3 − 2(4) = −5 and y = 4 − 3(3) = −5.
T_J = \begin{bmatrix} 0 & -2 \\ -3 & 0 \end{bmatrix},\quad \lambda^2 = 6,\quad \rho = \sqrt{6} \approx 2.449Eigenvalues of T_J (see eigenvalues and eigenvectors); ρ > 1.
3x + y = 4,\quad x + 2y = 3
Swap the equations; now |3| > 1 and |2| > 1.
T_J = \begin{bmatrix} 0 & -\tfrac{1}{3} \\ -\tfrac{1}{2} & 0 \end{bmatrix},\quad \lambda^2 = \dfrac{1}{6},\quad \rho \approx 0.408Now ρ < 1.
(0, 0) \to (1.333, 1.5) \to (0.833, 0.833) \to (1.056, 1.083)
x = (4 − y)/3 and y = (3 − x)/2.
Answer: as written, the iterates grow by about 2.449 times per step and blow up. After swapping the equations, they converge to (1, 1).
Example 5: Temperatures in a metal plate (word problem)
A thin metal plate has three interior points in a row. The top edge is held at 100°C, the bottom at 0°C, the left at 40°C and the right at 80°C. At steady state, each interior temperature is the average of its four neighbors. Set up the system and do three Jacobi iterations from 0.
T_1 = \dfrac{40 + 100 + 0 + T_2}{4} \Rightarrow 4T_1 - T_2 = 140Point 1: left edge, top, bottom and T₂.
T_2 = \dfrac{T_1 + 100 + 0 + T_3}{4} \Rightarrow -T_1 + 4T_2 - T_3 = 100Point 2: T₁, top, bottom and T₃.
T_3 = \dfrac{T_2 + 100 + 0 + 80}{4} \Rightarrow -T_2 + 4T_3 = 180Point 3: T₂, top, bottom and right edge.
T^{(1)} = \left(\dfrac{140}{4}, \dfrac{100}{4}, \dfrac{180}{4}\right) = (35, 25, 45)Iteration 1 from (0, 0, 0).
T^{(2)} = \left(\dfrac{140 + 25}{4}, \dfrac{100 + 35 + 45}{4}, \dfrac{180 + 25}{4}\right) = (41.25, 45, 51.25)Iteration 2 uses (35, 25, 45).
T^{(3)} = \left(\dfrac{140 + 45}{4}, \dfrac{100 + 41.25 + 51.25}{4}, \dfrac{180 + 45}{4}\right) = (46.25, 48.125, 56.25)Iteration 3 uses (41.25, 45, 51.25).
Answer: after three iterations the temperatures are about 46.3°C, 48.1°C and 56.3°C. Further iterations approach the exact steady state (335/7, 360/7, 405/7) ≈ (47.86, 51.43, 57.86)°C; iteration 8 gives (47.84, 51.42, 57.84).
Common mistakes
| Mistake | Example of the error | Fix |
|---|---|---|
| Using new values within the same iteration | In Example 2, using x⁽²⁾ = 1.1 to find y⁽²⁾ | Jacobi uses only iteration-k values; using new values right away is the Gauss-Seidel method. |
| Skipping the convergence check | Running Jacobi on x + 2y = 3, 3x + y = 4 as written | Check diagonal dominance (or ρ(T_J) < 1) first; reorder the equations if needed. |
| Thinking “not dominant” means “diverges” | Rejecting a system whose row 1 has 2 = 1 + 1 | Dominance is only sufficient; check ρ(T_J) for a definite answer. |
| Sign errors when isolating a variable | Writing y = (−8 + 2x + z)/8 for 2x + 8y − z = −8 | Move each term across with its sign changed: y = (−8 − 2x + z)/8. |
| Stopping after one small change in one variable | Stopping when x changes by 0.001 but z changes by 0.2 | Use the largest change over all variables. |
Related methods
Gauss-Seidel method
The Gauss-Seidel method uses each new value as soon as it is computed. It usually converges about twice as fast as Jacobi, but the updates can no longer be done in parallel.
Weighted Jacobi
Weighted (damped) Jacobi mixes the new and old values: x⁽ᵏ⁺¹⁾ = ω · (Jacobi update) + (1 − ω) · x⁽ᵏ⁾, often with ω = 2/3. It is a common smoother in multigrid solvers.
Practice problems
- Do two Jacobi iterations from (0, 0) for 6x − 2y = 10 and x + 4y = 6.
- Is \begin{bmatrix} 3 & -1 & 1 \\ 1 & -4 & 2 \\ 2 & 2 & 5 \end{bmatrix} strictly diagonally dominant?
- Is \begin{bmatrix} 2 & 1 & 1 \\ 1 & 3 & 1 \\ 1 & 1 & 2 \end{bmatrix} strictly diagonally dominant?
- In Example 1, find the largest change between iterations 1 and 2.
- Do three Jacobi iterations from (0, 0) for 2x − y = 1 and −x + 2y = 1.
- Find the spectral radius of T_J for 4x + y = 9 and x + 5y = 7. About how much does the error shrink each iteration?
- Will Jacobi converge for x + 3y = 5 and 4x − y = 7 as written? If not, fix it and give the solution.
- Continue Example 1 to iteration 5. With tolerance 0.01 on the largest change, at which iteration do you stop?
- A rod has two interior points with 2T₁ − T₂ = 100 and −T₁ + 2T₂ = 40. Do three Jacobi iterations from 0 and find the exact solution.
- Why can all the Jacobi updates in one iteration be computed at the same time?
Show answers
1.
x = \dfrac{10 + 2y}{6},\quad y = \dfrac{6 - x}{4}Solve for the diagonal variables.
x^{(1)} = \dfrac{10}{6} \approx 1.6667,\quad y^{(1)} = \dfrac{6}{4} = 1.5Iteration 1.
x^{(2)} = \dfrac{10 + 3}{6} \approx 2.1667,\quad y^{(2)} = \dfrac{6 - \tfrac{5}{3}}{4} = \dfrac{13}{12} \approx 1.0833Iteration 2 uses (5/3, 1.5).
Answer: (2.1667, 1.0833); the exact solution is (2, 1)
2.
3 \gt 1 + 1,\quad 4 \gt 1 + 2,\quad 5 \gt 2 + 2
Compare |aᵢᵢ| with the sum of the other |aᵢⱼ| in each row.
Answer: yes
3.
2 = 1 + 1
Row 1 is not strictly greater.
Answer: no (rows 1 and 3 have equality), so the dominance test does not guarantee convergence
4.
|1.9 - 2.25| = 0.35,\quad |0.95 - 1.4| = 0.45
Change in each variable.
Answer: 0.45
5.
x = \dfrac{1 + y}{2},\quad y = \dfrac{1 + x}{2}Jacobi formulas.
(0, 0) \to (0.5, 0.5) \to (0.75, 0.75) \to (0.875, 0.875)
Three iterations.
Answer: (0.875, 0.875), approaching (1, 1)
6.
T_J = \begin{bmatrix} 0 & -\tfrac{1}{4} \\ -\tfrac{1}{5} & 0 \end{bmatrix}T_J = −D⁻¹R.
\lambda^2 = \dfrac{1}{20},\quad \rho = \sqrt{0.05} \approx 0.2236Eigenvalues are ±√(1/20).
Answer: ρ ≈ 0.224, so the error shrinks to about 22% of its size each iteration
7.
T_J = \begin{bmatrix} 0 & -3 \\ 4 & 0 \end{bmatrix},\quad \lambda^2 = -12,\quad \rho = \sqrt{12} \approx 3.46As written, ρ > 1: it diverges.
4x - y = 7,\quad x + 3y = 5
Swap the equations; now strictly diagonally dominant.
x = \dfrac{7 + y}{4} \Rightarrow \dfrac{7 + y}{4} + 3y = 5 \Rightarrow 13y = 13Substitute to find the exact solution.
y = 1,\quad x = \dfrac{7 + 1}{4} = 2Back-substitute.
Answer: no as written; after swapping, Jacobi converges to (2, 1)
8.
x^{(5)} = \dfrac{9 - 0.9975}{4} = 2.000625,\quad y^{(5)} = \dfrac{7 - 1.995}{5} = 1.001Iteration 5 uses (1.995, 0.9975).
\max(|1.995 - 2.0125|, |0.9975 - 1.02|) = 0.0225
Change at iteration 4: still above 0.01.
\max(|2.000625 - 1.995|, |1.001 - 0.9975|) = 0.005625
Change at iteration 5: below 0.01.
Answer: stop at iteration 5 with (2.000625, 1.001)
9.
T_1 = \dfrac{100 + T_2}{2},\quad T_2 = \dfrac{40 + T_1}{2}Jacobi formulas.
(0, 0) \to (50, 20) \to (60, 45) \to (72.5, 50)
Three iterations.
-T_1 + 2T_2 = 40 \Rightarrow T_1 = 2T_2 - 40
Solve the second equation for T₁.
2(2T_2 - 40) - T_2 = 100 \Rightarrow 3T_2 = 180 \Rightarrow T_2 = 60
Substitute into the first.
T_1 = 2(60) - 40 = 80
Back-substitute.
Answer: iteration 3 gives (72.5, 50); the exact solution is T₁ = 80, T₂ = 60
10.
Answer: each new xᵢ depends only on the previous iterate, not on any other new value, so the n updates are independent and can run in parallel
Jacobi method FAQ
What is the Jacobi method?
It is an iterative method for Ax = b that solves each equation for its diagonal variable and updates all variables at once from the previous guess, repeating until the changes are small.
When does the Jacobi method converge?
It converges for every starting guess when the coefficient matrix is strictly diagonally dominant. The exact condition is that the spectral radius of the iteration matrix T_J = −D⁻¹R is less than 1.
What is the difference between the Jacobi and Gauss-Seidel methods?
Jacobi computes every new value from the old iterate. Gauss-Seidel uses each new value as soon as it is available, which usually makes it converge faster but harder to run in parallel.
How do you know when to stop the Jacobi method?
Stop when the largest change in any variable between iterations is below your tolerance, or when the residual b − Ax is small. Also set a maximum number of iterations in case the method does not converge.
Summary
- The Jacobi method solves equation i for xᵢ and updates all variables from the previous iterate.
- Formula: xᵢ⁽ᵏ⁺¹⁾ = (bᵢ − Σⱼ≠ᵢ aᵢⱼ xⱼ⁽ᵏ⁾) / aᵢᵢ.
- Strict diagonal dominance guarantees convergence; the exact test is ρ(T_J) < 1.
- Reordering the equations can make a system diagonally dominant.
- Stop when the largest change is below the tolerance.
Previous lesson: Partial Pivoting
Next lesson: Gauss-Seidel Method
Back to the Numerical Methods Index