Tutorials › Linear Algebra › Deriving the Jacobi Iteration

LU Factorization and Numerical Considerations · Tutorial 927 of 1000

Deriving the Jacobi Iteration

Learn to derive the Jacobi update from a linear system and apply it carefully from a specified initial guess.

Intermediate 10 min read

What You'll Learn

  • Split a system matrix into its diagonal part and its off-diagonal remainder.
  • Derive the Jacobi update from the original equations.
  • Identify when the diagonal-matrix inverse required by the update exists.
  • Explain why fixed points of the update are exactly solutions of the system.
  • Compute successive iterates using only the previous iterate.
  • Check an iteration by substitution and distinguish Jacobi updates from sequential updates.

From a Linear System to an Iteration

Gaussian elimination aims to solve a linear system in a finite sequence of steps. An iterative method takes a different approach: it starts with an initial guess and repeatedly applies a rule that is intended to produce better approximations. The Jacobi iteration is one such rule. Its derivation comes directly from separating the diagonal terms of the equations from all the other terms.

Consider a square system \(\mathbf{A}\mathbf{x}=\mathbf{b}\), where \(\mathbf{A}\in\mathbb{R}^{n\times n}\), \(\mathbf{x},\mathbf{b}\in\mathbb{R}^n\), and each diagonal entry \(a_{ii}\) is nonzero. The condition on the diagonal entries is essential: the update will require division by each \(a_{ii}\). Define \(\mathbf{D}\) to be the diagonal matrix with the same diagonal entries as \(\mathbf{A}\), and let \(\mathbf{R}\) contain the off-diagonal entries of \(\mathbf{A}\).

Definition: The diagonal and off-diagonal splitting of \(\mathbf{A}\) is \(\mathbf{A}=\mathbf{D}+\mathbf{R}\), where \(\mathbf{D}=\operatorname{diag}(a_{11},\dots,a_{nn})\) and \(\mathbf{R}=\mathbf{A}-\mathbf{D}\). Thus \(r_{ii}=0\) for every \(i\). When every \(a_{ii}\ne0\), the Jacobi iteration is the sequence defined from an initial guess \(\mathbf{x}^{(0)}\) by \(\mathbf{x}^{(k+1)}=\mathbf{D}^{-1}(\mathbf{b}-\mathbf{R}\mathbf{x}^{(k)})\) for \(k=0,1,2,\dots\).

To derive the rule, write \(\mathbf{A}\mathbf{x}=\mathbf{b}\) as \((\mathbf{D}+\mathbf{R})\mathbf{x}=\mathbf{b}\). Rearranging gives \(\mathbf{D}\mathbf{x}=\mathbf{b}-\mathbf{R}\mathbf{x}\). Since the diagonal entries of \(\mathbf{D}\) are all nonzero, \(\mathbf{D}\) is invertible, with diagonal entries \(1/a_{ii}\) in its inverse. Applying \(\mathbf{D}^{-1}\) gives the fixed-point equation \(\mathbf{x}=\mathbf{D}^{-1}(\mathbf{b}-\mathbf{R}\mathbf{x})\). The iteration uses the right-hand side to construct a new vector from the current one.

In coordinates, the \(i\)th equation of the original system is \(a_{ii}x_i+\sum_{j\ne i}a_{ij}x_j=b_i\). Solving this equation for \(x_i\), then using the old coordinates to calculate the new ones, gives

$$ x_i^{(k+1)} = \frac{1}{a_{ii}}\left(b_i-\sum_{j\ne i}a_{ij}x_j^{(k)}\right), \qquad i=1,\dots,n. $$

Every new coordinate uses coordinates from the same previous iterate \(\mathbf{x}^{(k)}\). The updates are therefore computed as a group: a value calculated for one coordinate is not inserted into the formula for another coordinate until the next iteration.

Why the Fixed Points Are Solutions

Theorem: Suppose \(\mathbf{A}\in\mathbb{R}^{n\times n}\) has no zero diagonal entries, and define \(\mathbf{D}\) and \(\mathbf{R}\) as above. A vector \(\mathbf{x}\in\mathbb{R}^n\) is a fixed point of the Jacobi update if and only if \(\mathbf{A}\mathbf{x}=\mathbf{b}\).

Proof. A vector is a fixed point precisely when \(\mathbf{x}=\mathbf{D}^{-1}(\mathbf{b}-\mathbf{R}\mathbf{x})\). Multiplying both sides by the invertible matrix \(\mathbf{D}\) gives \(\mathbf{D}\mathbf{x}=\mathbf{b}-\mathbf{R}\mathbf{x}\), or \((\mathbf{D}+\mathbf{R})\mathbf{x}=\mathbf{b}\). By the definition of the splitting, \(\mathbf{D}+\mathbf{R}=\mathbf{A}\), so this is \(\mathbf{A}\mathbf{x}=\mathbf{b}\). Conversely, if \(\mathbf{A}\mathbf{x}=\mathbf{b}\), then \((\mathbf{D}+\mathbf{R})\mathbf{x}=\mathbf{b}\), hence \(\mathbf{D}\mathbf{x}=\mathbf{b}-\mathbf{R}\mathbf{x}\). Multiplication by \(\mathbf{D}^{-1}\) gives the fixed-point equation. Thus each condition implies the other. \(\square\)

This result identifies what the iteration is trying to reach, but it does not say that the sequence reaches a fixed point. The existence of a well-defined update only requires nonzero diagonal entries; whether repeated updates converge is a separate question.

Computing Successive Iterates

Worked Example: Two Jacobi Updates for a Two-Variable System

Apply two Jacobi updates to \(4x_1+x_2=9\), \(x_1+3x_2=7\), starting from \(\mathbf{x}^{(0)}=\begin{bmatrix}0\\0\end{bmatrix}\).

The coefficient matrix splits into its diagonal part and off-diagonal part as follows:

$$ \mathbf{A}= \begin{bmatrix}4&1\\1&3\end{bmatrix} = \begin{bmatrix}4&0\\0&3\end{bmatrix} + \begin{bmatrix}0&1\\1&0\end{bmatrix} =\mathbf{D}+\mathbf{R}. $$

The coordinate updates are \(x_1^{(k+1)}=(9-x_2^{(k)})/4\) and \(x_2^{(k+1)}=(7-x_1^{(k)})/3\). Using the initial guess gives

$$ x_1^{(1)}=\frac{9-0}{4}=\frac94, \qquad x_2^{(1)}=\frac{7-0}{3}=\frac73, \qquad \mathbf{x}^{(1)}=\begin{bmatrix}\frac94\\[2pt]\frac73\end{bmatrix}. $$

For the second update, both formulas use the coordinates of \(\mathbf{x}^{(1)}\):

$$ x_1^{(2)}=\frac{9-\frac73}{4} =\frac{\frac{20}{3}}{4} =\frac53, \qquad x_2^{(2)}=\frac{7-\frac94}{3} =\frac{\frac{19}{4}}{3} =\frac{19}{12}, \qquad \mathbf{x}^{(2)}=\begin{bmatrix}\frac53\\[2pt]\frac{19}{12}\end{bmatrix}. $$

Check: Substitution of \(\mathbf{x}^{(2)}\) into the update formulas gives \((9-19/12)/4=89/48\) and \((7-5/3)/3=16/9\), so it produces the next iterate \(\mathbf{x}^{(3)}=\begin{bmatrix}89/48\\16/9\end{bmatrix}\). Also, direct multiplication gives \(\mathbf{A}\mathbf{x}^{(2)}=\begin{bmatrix}20/3+19/12\\5/3+19/4\end{bmatrix}=\begin{bmatrix}33/4\\77/12\end{bmatrix}\), which differs from \(\mathbf{b}=\begin{bmatrix}9\\7\end{bmatrix}\). The second iterate is an approximation, not an exact solution.

The matrix form can also be written as \(\mathbf{x}^{(k+1)}=\mathbf{D}^{-1}\mathbf{b}-\mathbf{D}^{-1}\mathbf{R}\mathbf{x}^{(k)}\). This form makes the repeated operation explicit: multiply the current vector by a fixed matrix, then add a fixed vector. It also confirms that the update is defined whenever \(\mathbf{D}\) is invertible.

Worked Example: Three Updates for a Three-Variable System

Use Jacobi iteration on \(4x_1+x_2+x_3=6\), \(x_1+5x_2+x_3=7\), and \(x_1+x_2+3x_3=5\), starting from \(\mathbf{x}^{(0)}=\begin{bmatrix}0\\0\\0\end{bmatrix}\). The matrix has diagonal entries \(4,5,3\), so the update is defined.

Solving each equation for its diagonal variable gives \(x_1^{(k+1)}=(6-x_2^{(k)}-x_3^{(k)})/4\), \(x_2^{(k+1)}=(7-x_1^{(k)}-x_3^{(k)})/5\), and \(x_3^{(k+1)}=(5-x_1^{(k)}-x_2^{(k)})/3\). From the zero initial guess,

$$ \mathbf{x}^{(1)} = \begin{bmatrix} 6/4\\7/5\\5/3 \end{bmatrix} = \begin{bmatrix} 3/2\\7/5\\5/3 \end{bmatrix}. $$

Using only these three old coordinates, the next iterate is

$$ \begin{aligned} x_1^{(2)}&=\frac{6-\frac75-\frac53}{4}=\frac{11}{15},& x_2^{(2)}&=\frac{7-\frac32-\frac53}{5}=\frac{23}{30},& x_3^{(2)}&=\frac{5-\frac32-\frac75}{3}=\frac{7}{10},\\ \mathbf{x}^{(2)}&=& \begin{bmatrix}11/15\\23/30\\7/10\end{bmatrix}. \end{aligned} $$

For a third update, use \(\mathbf{x}^{(2)}\) in every coordinate formula:

$$ \begin{aligned} x_1^{(3)}&=\frac{6-\frac{23}{30}-\frac{7}{10}}{4}=\frac{17}{15},& x_2^{(3)}&=\frac{7-\frac{11}{15}-\frac{7}{10}}{5}=\frac{167}{150},& x_3^{(3)}&=\frac{5-\frac{11}{15}-\frac{23}{30}}{3}=\frac76,\\ \mathbf{x}^{(3)}&=& \begin{bmatrix}17/15\\167/150\\7/6\end{bmatrix}. \end{aligned} $$

Check: Substituting \(\mathbf{x}^{(3)}\) into the original left-hand sides gives \(4(17/15)+167/150+7/6=6+61/75\), \(17/15+5(167/150)+7/6=7+13/15\), and \(17/15+167/150+3(7/6)=5+56/75\). Thus \(\mathbf{A}\mathbf{x}^{(3)}-\mathbf{b}=\begin{bmatrix}61/75\\13/15\\56/75\end{bmatrix}\). As a separate check that the system has a solution, \(\begin{bmatrix}1\\1\\1\end{bmatrix}\) gives left-hand sides \(6,7,5\), respectively. The computed iterate is not that exact solution.

Reading the Update as a Matrix Formula

In the two-variable example, \(\mathbf{D}^{-1}=\begin{bmatrix}1/4&0\\0&1/3\end{bmatrix}\). The full Jacobi update can therefore be written

$$ \mathbf{x}^{(k+1)} = \begin{bmatrix}1/4&0\\0&1/3\end{bmatrix} \left( \begin{bmatrix}9\\7\end{bmatrix} - \begin{bmatrix}0&1\\1&0\end{bmatrix} \mathbf{x}^{(k)} \right). $$

The diagonal part determines the division used for each new coordinate; the off-diagonal part collects the contributions from the other coordinates. This organization is useful because it turns a system of equations into a uniform rule that can be repeated. In applications with many variables, the update can be implemented by repeatedly using the known diagonal entries and the off-diagonal interactions.

There is an important limitation in the derivation. If any \(a_{ii}=0\), then \(\mathbf{D}^{-1}\) does not exist, and the displayed Jacobi rule cannot be applied in this form. A zero diagonal entry is not repaired by simply dividing by it; the system or method must first be reconsidered. Even when all diagonal entries are nonzero, the derivation alone gives no guarantee that successive iterates approach a solution.

Common Mistake: Updating Coordinates in Sequence

For the first example with \(\mathbf{x}^{(0)}=\begin{bmatrix}0\\0\end{bmatrix}\), the correct first iterate is \(\mathbf{x}^{(1)}=\begin{bmatrix}9/4\\7/3\end{bmatrix}\). A tempting but incorrect calculation is to find \(x_1^{(1)}=9/4\), then use that newly calculated value to set \(x_2^{(1)}=(7-9/4)/3=19/12\). That produces \(\begin{bmatrix}9/4\\19/12\end{bmatrix}\), not the Jacobi iterate, because the second coordinate formula must use \(x_1^{(0)}=0\). The correction is to compute every coordinate from the same old vector first; only then do the new coordinates form \(\mathbf{x}^{(1)}\).

Another useful check is to distinguish an iterate from a solution. An iterate is obtained by applying the update, while a solution satisfies \(\mathbf{A}\mathbf{x}=\mathbf{b}\). They coincide at a fixed point, as proved above, but an intermediate iterate need not satisfy the system exactly. Substitution into the original equations, or multiplication to find \(\mathbf{A}\mathbf{x}^{(k)}-\mathbf{b}\), checks how far the computed vector is from being an exact solution.

Worked Example: One Update from a Nonzero Initial Guess

Apply one Jacobi update to \(2x_1-x_2=1\), \(3x_1+4x_2=10\), starting from \(\mathbf{x}^{(0)}=\begin{bmatrix}1\\-1\end{bmatrix}\).

Here \(\mathbf{D}=\begin{bmatrix}2&0\\0&4\end{bmatrix}\) and \(\mathbf{R}=\begin{bmatrix}0&-1\\3&0\end{bmatrix}\). The coordinate rules are \(x_1^{(k+1)}=(1+x_2^{(k)})/2\) and \(x_2^{(k+1)}=(10-3x_1^{(k)})/4\). Thus

$$ x_1^{(1)}=\frac{1+(-1)}{2}=0, \qquad x_2^{(1)}=\frac{10-3(1)}{4}=\frac74, \qquad \mathbf{x}^{(1)}=\begin{bmatrix}0\\7/4\end{bmatrix}. $$

Check: The update matrix expression gives \(\mathbf{R}\mathbf{x}^{(0)}=\begin{bmatrix}1\\3\end{bmatrix}\), so \(\mathbf{D}^{-1}(\mathbf{b}-\mathbf{R}\mathbf{x}^{(0)})=\begin{bmatrix}1/2&0\\0&1/4\end{bmatrix}\begin{bmatrix}0\\7\end{bmatrix}=\begin{bmatrix}0\\7/4\end{bmatrix}\). Multiplying the new iterate by \(\mathbf{A}\) gives \(\begin{bmatrix}-7/4\\7\end{bmatrix}\), which differs from \(\mathbf{b}=\begin{bmatrix}1\\10\end{bmatrix}\), as expected for an intermediate iterate.

Check Your Understanding

Use the splitting and update rule to answer each question. Keep all coordinates in one update based on the same previous iterate.

  1. For \(\mathbf{A}=\begin{bmatrix}5&-2\\1&3\end{bmatrix}\), write \(\mathbf{D}\), \(\mathbf{R}\), and the two coordinate update formulas for \(\mathbf{A}\mathbf{x}=\begin{bmatrix}4\\8\end{bmatrix}\).
  2. Starting from \(\mathbf{x}^{(0)}=\begin{bmatrix}0\\0\end{bmatrix}\), compute one Jacobi update for the system in question 1.
  3. State the condition on the diagonal entries of \(\mathbf{A}\) that makes the Jacobi update as defined here available. Explain why it is needed.
  4. Prove that a fixed point of the Jacobi update solves \(\mathbf{A}\mathbf{x}=\mathbf{b}\).
  5. For the system \(2x_1-x_2=1\), \(3x_1+4x_2=10\), explain why using a newly computed \(x_1\) immediately in the same update for \(x_2\) does not follow the Jacobi rule.

Test yourself: Linear Algebra final exam practice

Ready to check what you know? Work a full-length practice final, then open the complete worked solutions.

Want all 1,114 practice problems?

This tutorial covers one topic. Calc Pass covers the full Calculus AB & BC curriculum (the core of Calculus I and II): full review, every practice question, and step-by-step solutions to each one.

QR code to download the Calc Pass app

Get the Calc Pass App

Scan to download and practice on the go, with instant scoring.

Calc Pass Volume 1: 1,114 Practice Questions book cover

Vol. 1: 1,114 Questions

The complete practice question bank, organized by AB & BC topic.

View on Amazon
Calc Pass Volume 2: Solutions Manual book cover

Vol. 2: Solutions Manual

Fully worked solutions to every question in Volume 1.

View on Amazon