5.3 The Jacobi and Gauss–Seidel methods

The Jacobi method

Solve the \(i\)th equation of \(A\mathbf x = \mathbf b\) for \(x_i\) (assuming \(a_{ii}\neq 0\)) and use the old values on the right: \begin {equation} \label {eq:jacobi} x_i^{(k)} = \frac {1}{a_{ii}}\left (b_i-\sum _{j\neq i}a_{ij}x_j^{(k-1)}\right ),\qquad i = 1,\dots ,n . \end {equation}

Example 5.3.1. Apply the Jacobi method, from \(\mathbf x^{(0)} = \mathbf 0\), to \begin {align*} 10x_1-x_2+2x_3 &= 6,\\ -x_1+11x_2-x_3+3x_4 &= 25,\\ 2x_1-x_2+10x_3-x_4 &= -11,\\ 3x_2-x_3+8x_4 &= 15, \end {align*}

whose solution is \(\mathbf x = (1,2,-1,1)^T\).

Solution. The iteration is \begin {align*} x_1^{(k)} &= \tfrac {1}{10}x_2^{(k-1)}-\tfrac 15x_3^{(k-1)}+\tfrac 35,\\ x_2^{(k)} &= \tfrac 1{11}x_1^{(k-1)}+\tfrac 1{11}x_3^{(k-1)}-\tfrac 3{11}x_4^{(k-1)}+\tfrac {25}{11},\\ x_3^{(k)} &= -\tfrac 15x_1^{(k-1)}+\tfrac 1{10}x_2^{(k-1)}+\tfrac 1{10}x_4^{(k-1)}-\tfrac {11}{10},\\ x_4^{(k)} &= -\tfrac 38x_2^{(k-1)}+\tfrac 18x_3^{(k-1)}+\tfrac {15}8 . \end {align*}

\(k\) \(x_1^{(k)}\) \(x_2^{(k)}\) \(x_3^{(k)}\) \(x_4^{(k)}\) \(\frac {\|\mathbf x^{(k)}-\mathbf x^{(k-1)}\|_\infty }{\|\mathbf x^{(k)}\|_\infty }\)
\(1\) \(0.6000\) \(2.2727\) \(-1.1000\) \(1.8750\) \(1\)
\(2\) \(1.0473\) \(1.7159\) \(-0.8052\) \(0.8852\) \(0.577\)
\(3\) \(0.9326\) \(2.0533\) \(-1.0493\) \(1.1309\) \(0.164\)
\(5\) \(0.9890\) \(2.0114\) \(-1.0103\) \(1.0214\) \(0.0287\)
\(8\) \(1.0006\) \(1.9987\) \(-0.9990\) \(0.9989\) \(0.00235\)
\(10\) \(1.0001\) \(1.9998\) \(-0.9998\) \(0.9998\) \(0.00042\)

After \(10\) iterations the relative change is below \(10^{-3}\) and every component is within \(2.3\times 10^{-4}\) of the solution.

The Gauss–Seidel method

When \(x_i^{(k)}\) is computed, the new values \(x_1^{(k)},\dots ,x_{i-1}^{(k)}\) are already known and are presumably better than the old ones. The Gauss–Seidel method uses them at once: \begin {equation} \label {eq:gs} x_i^{(k)} = \frac {1}{a_{ii}}\left (b_i-\sum _{j<i}a_{ij}x_j^{(k)}-\sum _{j>i}a_{ij}x_j^{(k-1)}\right ),\qquad i = 1,\dots ,n . \end {equation} It also needs only one vector of storage, overwritten in place.

Example 5.3.2. Apply the Gauss–Seidel method to the system of Example 5.3.1.

Solution.

\(k\) \(x_1^{(k)}\) \(x_2^{(k)}\) \(x_3^{(k)}\) \(x_4^{(k)}\) relative change
\(1\) \(0.6000\) \(2.3273\) \(-0.9873\) \(0.8789\) \(1\)
\(2\) \(1.0302\) \(2.0369\) \(-1.0145\) \(0.9843\) \(0.211\)
\(3\) \(1.0066\) \(2.0036\) \(-1.0025\) \(0.9984\) \(0.0167\)
\(4\) \(1.0009\) \(2.0003\) \(-1.0003\) \(0.9998\) \(0.0029\)
\(5\) \(1.0001\) \(2.0000\) \(-1.0000\) \(1.0000\) \(0.00038\)

Five Gauss–Seidel iterations do the work of ten Jacobi iterations. For instance \(x_2^{(1)} = \frac {1}{11}(0.6000)+\frac {25}{11} = 2.3273\) already uses the new \(x_1^{(1)}\).

Matrix form and convergence

Write \(A = D-L-U\), where \(D\) is the diagonal of \(A\) and \(-L\), \(-U\) are its strictly lower and upper triangular parts. Then the Jacobi method is \(D\mathbf x^{(k)} = (L+U)\mathbf x^{(k-1)}+\mathbf b\), and Gauss–Seidel is \((D-L)\mathbf x^{(k)} = U\mathbf x^{(k-1)}+\mathbf b\). Both have the form \begin {equation} \label {eq:stationary} \mathbf x^{(k)} = T\mathbf x^{(k-1)}+\mathbf c, \end {equation} with \[T_j = D^{-1}(L+U),\qquad T_g = (D-L)^{-1}U .\]

Theorem 5.3.3. For any \(\mathbf x^{(0)}\), the sequence (5.4) converges to the unique solution of \(\mathbf x = T\mathbf x+\mathbf c\) if and only if \(\rho (T)<1\). If \(\|T\|<1\) for some natural norm, then \[\|\mathbf x-\mathbf x^{(k)}\|\leq \|T\|^k\|\mathbf x^{(0)}-\mathbf x\|\qquad \text {and}\qquad \|\mathbf x-\mathbf x^{(k)}\|\leq \frac {\|T\|^k}{1-\|T\|}\|\mathbf x^{(1)}-\mathbf x^{(0)}\| .\]

Proof. If \(\rho (T)<1\), then \(1\) is not an eigenvalue of \(T\), so \(I-T\) is invertible and \(\mathbf x = T\mathbf x+\mathbf c\) has a unique solution. Subtracting it from (5.4), the error \(\mathbf e^{(k)} = \mathbf x^{(k)}-\mathbf x\) satisfies \(\mathbf e^{(k)} = T\mathbf e^{(k-1)} = \dots = T^k\mathbf e^{(0)}\), which tends to \(\mathbf 0\) for every \(\mathbf e^{(0)}\) by Theorem 5.2.4. Conversely, if \(\rho (T)\geq 1\), choose \(\mathbf x^{(0)}\) so that \(\mathbf e^{(0)}\) is an eigenvector for an eigenvalue with \(|\lambda |\geq 1\); then \(\mathbf e^{(k)} = \lambda ^k\mathbf e^{(0)}\) does not tend to \(\mathbf 0\). The bounds follow exactly as in the proof of the Fixed-Point Theorem 2.3.7, with \(|g'|\leq k\) replaced by \(\|T\|<1\). □

The rate of convergence is governed by \(\rho (T)\): the error is reduced roughly by the factor \(\rho (T)\) per iteration. For the system of Example 5.3.1, \(\rho (T_j) = 0.426\) and \(\rho (T_g) = 0.0898\), which is why Gauss–Seidel was so much faster.

Theorem 5.3.4. If \(A\) is strictly diagonally dominant, then both the Jacobi and the Gauss–Seidel methods converge for every \(\mathbf b\) and every \(\mathbf x^{(0)}\).

Proof. Jacobi. The \(i\)th row of \(T_j\) has entries \(-\frac {a_{ij}}{a_{ii}}\) (\(j\neq i\)) and \(0\) on the diagonal, so its absolute row sum is \(\frac {1}{|a_{ii}|}\sum _{j\neq i}|a_{ij}|<1\). Hence \(\rho (T_j)\leq \|T_j\|_\infty <1\).

Gauss–Seidel. Let \(\lambda \) be an eigenvalue of \(T_g\) with eigenvector \(\mathbf v\), scaled so that \(\|\mathbf v\|_\infty = 1\), and let \(|v_k| = 1\). From \(U\mathbf v = \lambda (D-L)\mathbf v\), the \(k\)th component reads \[-\sum _{j>k}a_{kj}v_j = \lambda \left (a_{kk}v_k+\sum _{j<k}a_{kj}v_j\right ).\] Taking absolute values and using \(|v_j|\leq 1\), \[|\lambda |\left (|a_{kk}|-\sum _{j<k}|a_{kj}|\right )\leq \sum _{j>k}|a_{kj}| .\] By strict diagonal dominance, \(|a_{kk}|-\sum _{j<k}|a_{kj}|>\sum _{j>k}|a_{kj}|\geq 0\), so \(|\lambda |<1\). Hence \(\rho (T_g)<1\). □

Example 5.3.5. Show that the Jacobi method diverges for \(x_1+2x_2 = 3\), \(3x_1+x_2 = 4\), and that it converges after the equations are interchanged.

Solution. Here \(T_j = \begin {pmatrix}0&-2\\-3&0\end {pmatrix}\), with eigenvalues \(\pm \sqrt 6\), so \(\rho (T_j) = 2.449>1\). From \(\mathbf 0\) the iterates are \((3,4), (-5,-5), (13,19), (-35,-35),\dots \), moving away from the solution \((1,1)\). Interchanging the equations gives \(3x_1+x_2 = 4\), \(x_1+2x_2 = 3\), which is strictly diagonally dominant, and now \(T_j = \begin {pmatrix}0&-\frac 13\\-\frac 12&0\end {pmatrix}\) has \(\rho = \frac 1{\sqrt 6} = 0.408\): the iteration converges.

Questions on this section

Stuck on something here? Ask below and it stays attached to this topic.