Gauss–Seidel method

1

In numerical linear algebra, the Gauss–Seidel method, also known as the Liebmann method or the method of successive displacement, is an iterative method used to solve a system of linear equations. It is named after the German mathematicians Carl Friedrich Gauss and Philipp Ludwig von Seidel. Though it can be applied to any matrix with non-zero elements on the diagonals, convergence is only guaranteed if the matrix is either strictly diagonally dominant, or symmetric and positive definite. It was only mentioned in a private letter from Gauss to his student Gerling in 1823. A publication was not delivered before 1874 by Seidel.

Description

Let be a square system of n linear equations, where: When \mathbf A and \mathbf b are known, and \mathbf x is unknown, the Gauss–Seidel method can be used to iteratively approximate \mathbf x. The vector denotes the initial guess for \mathbf x, often for i=1,2,...,n. Denote by the k-th approximation or iteration of \mathbf{x}, and by the approximation of \mathbf{x} at the next (or k+1-th) iteration.

Matrix-based formula

The solution is obtained iteratively via where the matrix \mathbf A is decomposed into a lower triangular component \mathbf L, and a strictly upper triangular component \mathbf U such that. More specifically, the decomposition of A into L_* and U is given by:

Why the matrix-based formula works

The system of linear equations may be rewritten as: The Gauss–Seidel method now solves the left hand side of this expression for \mathbf{x}, using the previous value for \mathbf{x} on the right hand side. Analytically, this may be written as

Element-based formula

However, by taking advantage of the triangular form of \mathbf L, the elements of can be computed sequentially for each row i using forward substitution: Notice that the formula uses two summations per iteration which can be expressed as one summation that uses the most recently calculated iteration of x_j. The procedure is generally continued until the changes made by an iteration are below some tolerance, such as a sufficiently small residual.

Discussion

The element-wise formula for the Gauss–Seidel method is related to that of the (iterative) Jacobi method, with an important difference: In Gauss-Seidel, the computation of uses the elements of that have already been computed, and only the elements of that have not been computed in the (k+1)-th iteration. This means that, unlike the Jacobi method, only one storage vector is required as elements can be overwritten as they are computed, which can be advantageous for very large problems. However, unlike the Jacobi method, the computations for each element are generally much harder to implement in parallel, since they can have a very long critical path, and are thus most feasible for sparse matrices. Furthermore, the values at each iteration are dependent on the order of the original equations. Gauss-Seidel is the same as successive over-relaxation with \omega=1.

Convergence

The convergence properties of the Gauss–Seidel method are dependent on the matrix \mathbf A. Namely, the procedure is known to converge if either: The Gauss–Seidel method may converge even if these conditions are not satisfied. Golub and Van Loan give a theorem for an algorithm that splits \mathbf A into two parts. Suppose is nonsingular. Let be the spectral radius of. Then the iterates defined by converge to for any starting vector if \mathbf M is nonsingular and r < 1.

Algorithm

Since elements can be overwritten as they are computed in this algorithm, only one storage vector is needed, and vector indexing is omitted. The algorithm goes as follows: algorithm Gauss–Seidel method is inputs: A, b output: φ Choose an initial guess φ to the solution repeat until convergence for i from 1 until n do σ ← 0 for j from 1 until n do if j ≠ i then σ ← σ + aijφj end if end (j-loop) φi ← (bi − σ) / aii end (i-loop) check if convergence is reached end (repeat)

Examples

An example for the matrix version

A linear system shown as is given by: Use the equation in the form where: Decompose \mathbf A into the sum of a lower triangular component \mathbf L and a strict upper triangular component U: The inverse of \mathbf L is: Now find: With \mathbf T and \mathbf c the vectors \mathbf{x} can be obtained iteratively. First of all, choose, for example The closer the guess to the final solution, the fewer iterations the algorithm will need. Then calculate: As expected, the algorithm converges to the solution: . In fact, the matrix A is strictly diagonally dominant, but not positive definite.

Another example for the matrix version

Another linear system shown as is given by: Use the equation in the form where: Decompose \mathbf A into the sum of a lower triangular component \mathbf L and a strict upper triangular component \mathbf U: The inverse of \mathbf L is: Now find: With \mathbf T and \mathbf c the vectors \mathbf{x} can be obtained iteratively. First of all, we have to choose, for example Then calculate: In a test for convergence we find that the algorithm diverges. In fact, the matrix \mathbf A is neither diagonally dominant nor positive definite. Then, convergence to the exact solution is not guaranteed and, in this case, will not occur.

An example for the equation version

Suppose given n equations and a starting point. At any step in a Gauss-Seidel iteration, solve the first equation for x_1 in terms of ; then solve the second equation for x_2 in terms of x_1 just found and the remaining ; and continue to x_n. Then, repeat iterations until convergence is achieved, or break if the divergence in the solutions start to diverge beyond a predefined level. Consider an example: Solving for and x_4 gives: Suppose (0, 0, 0, 0) is the initial approximation, then the first approximate solution is given by: Using the approximations obtained, the iterative procedure is repeated until the desired accuracy has been reached. The following are the approximated solutions after four iterations. The exact solution of the system is (1, 2, −1, 1) .

An example using Python and NumPy

The following iterative procedure produces the solution vector of a linear system of equations: Produces the output:

Program to solve arbitrary number of equations using Matlab

The following code uses the formula

This article is derived from Wikipedia and licensed under CC BY-SA 4.0. View the original article.

Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc.
Bliptext is not affiliated with or endorsed by Wikipedia or the Wikimedia Foundation.

Edit article