Skip to main content

24  Jacobi, Gauss-Seidel, and SOR Methods

Each row of a linear system can be solved for its diagonal unknown when that diagonal entry is nonzero. Jacobi uses the old values of every other unknown. Gauss–Seidel uses new values as soon as they are available. Relaxation changes how far each such update is taken. We derive these choices and then determine sufficient conditions for convergence.

For the matrix formulas we use \(\bA=\bD-\bL_A-\bU_A\), where \(\bD\) is diagonal and \(-\bL_A\), \(-\bU_A\) are the strictly lower and upper parts of \(\bA\). The minus signs are a convention. For example, if \(a_{21}=1\), then \((L_A)_{21}=-1\).

24.1 The Jacobi Method

Jacobi uses the diagonal as an easily solved approximation to the matrix. Strict diagonal dominance is a sufficient convergence condition, but is not part of the definition. It computes the \((k+1)\)-th estimate of each unknown \(x_i\) exclusively from the \(k\)-th estimates of all other variables.

NoteDefinition: Jacobi Iteration

Let \(\bA \in \fR^{n \times n}\) with nonzero diagonal entries \(a_{ii} \neq 0\). The Jacobi method corresponds to the splitting \(\bM = \bD\) and \(\mathbf{N} = \bL_A + \bU_A\). In component form, the update is \[ \begin{align} x_i^{(k+1)} = \frac{1}{a_{ii}} \left( b_i - \sum_{j \neq i} a_{ij} x_j^{(k)} \right), \qquad i = 1, 2, ..., n. \end{align} \] In matrix notation, the iteration is given by \[ \begin{align} \bx^{(k+1)} = \bT_J \bx^{(k)} + \bc_J, \end{align} \] where \(\bT_J = \bD^{-1}(\bL_A + \bU_A) = \bI - \bD^{-1}\bA\) is the Jacobi iteration matrix and \(\bc_J = \bD^{-1}\bb\).

TipRemark

(Parallel execution and memory) Because each component \(x_i^{(k+1)}\) depends only on values from the previous iteration vector \(\bx^{(k)}\), all \(n\) components can be computed concurrently. This fine-grained parallelism makes Jacobi attractive on vector and GPU hardware. However, it requires double buffering in memory to store \(\bx^{(k)}\) and \(\bx^{(k+1)}\) simultaneously.

24.2 The Gauss–Seidel Method

The Gauss–Seidel method uses updated variable values as soon as they become available within a sweep. This changes the iteration matrix, so its convergence must be examined separately.

NoteDefinition: Gauss–Seidel Iteration

Let \(\bA \in \fR^{n \times n}\) with nonzero diagonal entries. The Gauss–Seidel method corresponds to the triangular splitting \(\bM = \bD - \bL_A\) and \(\mathbf{N} = \bU_A\). In component form, the update is \[ \begin{align} x_i^{(k+1)} = \frac{1}{a_{ii}} \left( b_i - \sum_{j < i} a_{ij} x_j^{(k+1)} - \sum_{j > i} a_{ij} x_j^{(k)} \right), \qquad i = 1, 2, ..., n. \end{align} \] In matrix notation, the iteration is given by \[ \begin{align} (\bD - \bL_A) \bx^{(k+1)} = \bU_A \bx^{(k)} + \bb \iff \bx^{(k+1)} = \bT_{GS} \bx^{(k)} + \bc_{GS}, \end{align} \] where \(\bT_{GS} = (\bD - \bL_A)^{-1}\bU_A\) is the Gauss–Seidel iteration matrix and \(\bc_{GS} = (\bD - \bL_A)^{-1}\bb\).

WarningExercise

Compute the Jacobi and Gauss-Seidel iteration matrices for \(\bA = \begin{pmatrix} 2 & 1 \\ 1 & 2 \end{pmatrix}\). Find their spectral radii and verify that \(\rho(\bT_{GS}) = \rho(\bT_J)^2\).

TipRemark

(Sequential dependencies and in-place updates) Because the calculation of \(x_i^{(k+1)}\) requires the newly computed values \(x_1^{(k+1)}, ..., x_{i-1}^{(k+1)}\), the standard Gauss–Seidel sweep is inherently sequential. However, it permits in-place updates, in which new values immediately overwrite old values in a single vector. For the standard Poisson problem in the natural ordering, the Gauss–Seidel spectral radius is the square of the Jacobi spectral radius. Such a comparison needs structure and does not hold for arbitrary matrices.

NoteExample

(Comparison of one Jacobi and Gauss–Seidel step) Consider the linear system \[ \begin{align} \begin{pmatrix} 4 & 1 & 0 \\ 1 & 4 & 1 \\ 0 & 1 & 4 \end{pmatrix} \begin{pmatrix} x_1 \\ x_2 \\ x_3 \end{pmatrix} = \begin{pmatrix} 5 \\ 6 \\ 5 \end{pmatrix}, \end{align} \] whose exact solution is \(\bx^* = (1, 1, 1)^T\). Let the initial guess be \(\bx^{(0)} = (0, 0, 0)^T\).

  • Jacobi Step: \[ \begin{align} x_1^{(1)} &= \frac{1}{4}(5 - 0 - 0) = 1.25, \\ x_2^{(1)} &= \frac{1}{4}(6 - 0 - 0) = 1.50, \\ x_3^{(1)} &= \frac{1}{4}(5 - 0 - 0) = 1.25, \qquad \implies \bx_J^{(1)} = \begin{pmatrix} 1.25 \\ 1.50 \\ 1.25 \end{pmatrix}. \end{align} \]

  • Gauss–Seidel Step: \[ \begin{align} x_1^{(1)} &= \frac{1}{4}(5 - 0 - 0) = 1.25, \\ x_2^{(1)} &= \frac{1}{4}(6 - (1.25) - 0) = \frac{4.75}{4} = 1.1875, \\ x_3^{(1)} &= \frac{1}{4}(5 - (1.1875) - 0) = \frac{3.8125}{4} \approx 0.9531, \qquad \implies \bx_{GS}^{(1)} \approx \begin{pmatrix} 1.2500 \\ 1.1875 \\ 0.9531 \end{pmatrix}. \end{align} \]

The Gauss–Seidel iterate is closer to the true solution \((1, 1, 1)^T\) because the update for \(x_2\) immediately used the new value of \(x_1\), and the update for \(x_3\) used the new value of \(x_2\).

24.3 Convergence Theorems

NoteTheorem: Convergence Under Strict Diagonal Dominance

A matrix \(\bA \in \fR^{n \times n}\) is strictly diagonally dominant if \[ \begin{align} |a_{ii}| > \sum_{j \neq i} |a_{ij}| \qquad \text{for all } i = 1, 2, ..., n. \end{align} \] If \(\bA\) is strictly diagonally dominant, then both the Jacobi iteration and the Gauss–Seidel iteration converge for any initial guess \(\bx^{(0)} \in \fR^n\).

We show that the matrix \(\infty\)-norm of the iteration matrix \(\bT_J = \bD^{-1}(\bL_A + \bU_A)\) is strictly bounded by one. The entries of \(\bT_J\) are \[ \begin{align} (\bT_J)_{ij} = \begin{cases} -\frac{a_{ij}}{a_{ii}}, & i \neq j, \\ 0, & i = j. \end{cases} \end{align} \] The induced \(\infty\)-norm is the maximum absolute row sum: \[ \begin{align} \|\bT_J\|_\infty = \max_{1 \leq i \leq n} \sum_{j=1}^n |(\bT_J)_{ij}| = \max_{1 \leq i \leq n} \sum_{j \neq i} \frac{|a_{ij}|}{|a_{ii}|}. \end{align} \] Because \(\bA\) is strictly diagonally dominant, \(|a_{ii}| > \sum_{j \neq i} |a_{ij}|\) for each \(i \in \{1, ..., n\}\), so \[ \begin{align} \sum_{j \neq i} \frac{|a_{ij}|}{|a_{ii}|} < 1 \implies \|\bT_J\|_\infty < 1. \end{align} \] By Gelfand’s spectral radius theorem, \(\rho(\bT_J) \leq \|\bT_J\|_\infty < 1\), which establishes convergence of the Jacobi iteration.

The estimate is uniform over all rows. Hence its maximum is a fixed number smaller than one, rather than a different bound for each iterate. Repeated multiplication by the iteration matrix then makes every Jacobi error tend to zero.

For Gauss–Seidel, let \(\lambda\) be an eigenvalue of \(\bT_{GS} = (\bD - \bL_A)^{-1}\bU_A\) with eigenvector \(\bv \neq \bzero\), normalized so that \(\|\bv\|_\infty = |v_p| = 1\). From \(\bU_A \bv = \lambda(\bD - \bL_A)\bv\), row \(p\) reads \[ \begin{align} -\sum_{j > p} a_{pj} v_j = \lambda a_{pp} v_p + \lambda \sum_{j < p} a_{pj} v_j. \end{align} \] Rearranging and applying the triangle inequality with \(|v_j| \leq 1\) yields \[ \begin{align} |\lambda| |a_{pp}| \leq \sum_{j > p} |a_{pj}| + |\lambda| \sum_{j < p} |a_{pj}|. \end{align} \] If \(|\lambda| \ge 1\), then \[ \begin{align} |a_{pp}| \leq \frac{1}{|\lambda|} \sum_{j > p} |a_{pj}| + \sum_{j < p} |a_{pj}| \leq \sum_{j \neq p} |a_{pj}|, \end{align} \] which contradicts strict diagonal dominance. The contradiction came from choosing an entry of maximal eigenvector magnitude. Such an entry is nonzero because the eigenvector is nonzero, so the normalization and divisions were legitimate. The index need not be the first or last row.

Hence \(|\lambda| < 1\), proving \(\rho(\bT_{GS}) < 1\).

NoteTheorem: Convergence of Gauss–Seidel for Symmetric Positive Definite Systems

If \(\bA \in \fR^{n \times n}\) is symmetric positive definite, then the Gauss–Seidel method converges for every initial vector \(\bx^{(0)} \in \fR^n\). The Jacobi method, however, is not guaranteed to converge for arbitrary SPD matrices.

Let \(\bx^*\) be the exact solution and define \(\phi(\bx)=\tfrac12\bx^T\bA\bx-\bb^T\bx\). During a sweep, let \(\by\) denote the vector after any preceding coordinate updates, and let \(r_i=b_i-(\bA\by)_i\) be its current residual entry.

Changing only coordinate \(i\) by \(d\) gives \[ \begin{align} \phi(\by+d\be_i)-\phi(\by)=-dr_i+\tfrac12a_{ii}d^2. \end{align} \] The diagonal entry is positive because \(\bA\) is SPD. Completing the square gives \[ \begin{align} -dr_i+\tfrac12a_{ii}d^2 =\tfrac12a_{ii}(d-r_i/a_{ii})^2-\frac{r_i^2}{2a_{ii}}. \end{align} \] The Gauss–Seidel update is exactly \(d=r_i/a_{ii}\), using all coordinates at their current values. It minimizes this expression and decreases \(\phi\) by \(a_{ii}d^2/2\).

Sum the decreases over the sweep. They are all nonnegative. Their sum vanishes only when every coordinate change is zero. If no coordinate changes, the vector remains the same throughout the sweep, and \(r_i=0\) when each row is visited. All rows are therefore satisfied, so the vector is \(\bx^*\).

The energy identity gives \(\phi(\by)-\phi(\bx^*)=\tfrac12\|\by-\bx^*\|_{\bA}^2\). Thus one sweep strictly decreases the energy norm of every nonzero error. Let \(\bT_{GS}\) be its linear error map. The function \(\be\mapsto\|\bT_{GS}\be\|_{\bA}\) is continuous on the compact energy-unit sphere. Its attained maximum is a number \(q<1\), because every value there is strictly less than one. Homogeneity yields \(\|\bT_{GS}\be\|_{\bA}\leq q\|\be\|_{\bA}\) for every error. Repeating sweeps gives \(\|\be^{(k)}\|_{\bA}\leq q^k\|\be^{(0)}\|_{\bA}\to0\). This proves convergence. See also Saad (2003) for stationary-iteration theory.

WarningExercise

Complete the square for a coordinate update and derive the decrease \(a_{ii}d_i^2/2\). To see why the same conclusion need not hold for Jacobi, take the \(3\times3\) matrix with diagonal entries \(1\) and all off-diagonal entries \(3/4\). Compute its eigenvalues and those of its Jacobi iteration matrix.

24.4 Successive Over-Relaxation (SOR)

In an SOR sweep, compute the value proposed by a Gauss–Seidel coordinate update and take a fraction \(\omega\) of the change. Values \(0<\omega<1\) shorten the change. Values \(\omega>1\) extend it. This can accelerate convergence for a suitable matrix and parameter, but can also cause divergence.

NoteDefinition: Successive Over-Relaxation Scheme

Let \(\omega > 0\) be a relaxation parameter. The SOR method computes the updated components via \[ \begin{align} x_i^{(k+1)} = (1 - \omega) x_i^{(k)} + \frac{\omega}{a_{ii}} \left( b_i - \sum_{j < i} a_{ij} x_j^{(k+1)} - \sum_{j > i} a_{ij} x_j^{(k)} \right). \end{align} \] In matrix notation, this corresponds to the splitting \(\bM_\omega = \frac{1}{\omega}\bD - \bL_A\) and \(\mathbf{N}_\omega = \left( \frac{1}{\omega} - 1 \right)\bD + \bU_A\). The iteration matrix is \[ \begin{align} \bT_\omega = (\bD - \omega \bL_A)^{-1} \left( (1 - \omega)\bD + \omega \bU_A \right). \end{align} \]

WarningExercise

Prove the Kahan theorem: for any matrix \(\bA\) with nonzero diagonal entries, \(\rho(\bT_\omega) \geq |\omega - 1|\), which implies that SOR can only converge if \(0 < \omega < 2\).

NoteTheorem: Ostrowski–Reich Theorem and the Optimal Parameter

If \(\bA\) is symmetric positive definite, then the SOR iteration converges if and only if the relaxation parameter satisfies \[ \begin{align} 0 < \omega < 2. \end{align} \] For the one-dimensional Dirichlet Poisson matrix in its natural ordering, with Jacobi spectral radius \(\rho(\bT_J)=\cos(\pi h)<1\), the optimal relaxation parameter that minimizes \(\rho(\bT_\omega)\) is \[ \begin{align} \omega^* = \frac{2}{1 + \sqrt{1 - \rho(\bT_J)^2}}. \end{align} \] With this optimal choice, the spectral radius satisfies \(\rho(\bT_{\omega^*}) = \omega^* - 1\).

Let \(\phi(\bx)=\tfrac12\bx^T\bA\bx-\bb^T\bx\), and consider the current vector just before coordinate \(i\) is updated. Write \(g_i=(\bA\bx-\bb)_i\). Holding the other coordinates fixed gives \[ \begin{align} \phi(\bx+d_i\be_i)-\phi(\bx)=g_i d_i+\tfrac12a_{ii}d_i^2. \end{align} \] The Gauss–Seidel change is \(-g_i/a_{ii}\). SOR takes \(d_i=-\omega g_i/a_{ii}\), so \(g_i=-a_{ii}d_i/\omega\). Substitution gives \[ \begin{align} \phi(\bx)-\phi(\bx+d_i\be_i) =\frac{a_{ii}(2-\omega)}{2\omega}d_i^2. \end{align} \] For an SPD matrix, \(a_{ii}>0\). Thus every nonzero coordinate change decreases the energy when \(0<\omega<2\).

Let \(\bx_*\) solve the system and let \(\be=\bx-\bx_*\). Expanding the quadratic and using \(\bA\bx_*=\bb\) gives \(\phi(\bx)-\phi(\bx_*)=\tfrac12\|\be\|_{\bA}^2\). A complete sweep therefore strictly reduces the error norm unless every coordinate change is zero. If all changes are zero, the vector remains fixed throughout the sweep, and \(g_i=0\) for every \(i\). It is then already the solution.

The error after a sweep is \(\bT_\omega\be\). The continuous function \(\be\mapsto\|\bT_\omega\be\|_{\bA}\) attains a maximum \(q\) on the compact unit sphere \(\|\be\|_{\bA}=1\). The strict decrease just proved holds at every point on that sphere, including a maximizing point, so \(q<1\). Scaling gives \(\|\bT_\omega\be\|_{\bA}\leq q\|\be\|_{\bA}\) for every error. After \(k\) sweeps the norm is at most \(q^k\) times its initial value, which tends to zero.

For necessity, the determinant exercise above gives \(\rho(\bT_\omega)\geq|\omega-1|\). Convergence requires spectral radius less than one, hence \(|\omega-1|<1\), or \(0<\omega<2\). The optimal-parameter formula for the Poisson problem is stated without proof; see the treatment of SOR in (Saad 2003).

TipRemark

(Acceleration for discrete Poisson equations) For the 1D discrete Laplacian on a grid with spacing \(h\), the Jacobi spectral radius is \(\rho(\bT_J) = \cos(\pi h) \approx 1 - \frac{1}{2}\pi^2 h^2\). Consequently, Jacobi and Gauss–Seidel require \(O(h^{-2}) = O(n^2)\) iterations to converge. With optimal SOR, \(\omega^* \approx 2 - 2\pi h\), yielding \(\rho(\bT_{\omega^*}) \approx 1 - 2\pi h\). This reduces the required iteration count to \(O(h^{-1}) = O(n)\), providing an order-of-magnitude computational speedup.

24.5 Further Exercises

WarningExercise

Let \(\bA = \begin{pmatrix} 1 & 2 \\ 2 & 1 \end{pmatrix}\). Show that \(\bA\) is symmetric but indefinite, and prove that both Jacobi and Gauss-Seidel diverge.

WarningExercise

Write a Python script to solve the 1D discrete Poisson equation with \(n=50\) grid points using Jacobi, Gauss-Seidel, and optimal SOR. Plot the residual norm versus iteration number on a semilogarithmic scale.