Iterative method used to solve a linear system of equations
In numerical linear algebra, the Jacobi method (a.k.a. the Jacobi iteration method) is an iterative algorithm for determining the solutions of a strictly diagonally dominant system of linear equations. Each diagonal element is solved for, and an approximate value is plugged in. The process is then iterated until it converges. This algorithm is a stripped-down version of the Jacobi transformation method of matrix diagonalization. The method is named after Carl Gustav Jacob Jacobi.
Description
Let
be a square system of n linear equations, where:
When
and
are known, and
is unknown, we can use the Jacobi method to approximate
. The vector
denotes our initial guess for
(often
for
). We denote
as the k-th approximation or iteration of
, and
is the next (or k+1) iteration of
.
Then A can be decomposed into a diagonal component D, a lower triangular part L and an upper triangular part U:
The solution is then obtained iteratively via
![{\displaystyle \mathbf {x} ^{(k+1)}=D^{-1}(\mathbf {b} -(L+U)\mathbf {x} ^{(k)}).}](https://wikimedia.org/api/rest_v1/media/math/render/svg/bb80f9663c6a20e592c5b522ac45e27bd10a8890)
The element-based formula for each row
is thus:
The computation of
requires each element in
except itself. Unlike the Gauss–Seidel method, we can't overwrite
with
, as that value will be needed by the rest of the computation. The minimum amount of storage is two vectors of size n.
Algorithm
Input: initial guess x(0) to the solution, (diagonal dominant) matrix A, right-hand side vector b, convergence criterion
Output: solution when convergence is reached
Comments: pseudocode based on the element-based formula above
k = 0
while convergence not reached do
for i := 1 step until n do
σ = 0
for j := 1 step until n do
if j ≠ i then
σ = σ + aij xj(k)
end
end
xi(k+1) = (bi − σ) / aii
end
increment k
end
Convergence
The standard convergence condition (for any iterative method) is when the spectral radius of the iteration matrix is less than 1:
![{\displaystyle \rho (D^{-1}(L+U))<1.}](https://wikimedia.org/api/rest_v1/media/math/render/svg/55a84dfad167d6872e52ce5b8f8cacb46c06b719)
A sufficient (but not necessary) condition for the method to converge is that the matrix A is strictly or irreducibly diagonally dominant. Strict row diagonal dominance means that for each row, the absolute value of the diagonal term is greater than the sum of absolute values of other terms:
![{\displaystyle \left|a_{ii}\right|>\sum _{j\neq i}{\left|a_{ij}\right|}.}](https://wikimedia.org/api/rest_v1/media/math/render/svg/5543526e4e4c4ce0e00f6e6ca94a0dfd8ce91e7a)
The Jacobi method sometimes converges even if these conditions are not satisfied.
Note that the Jacobi method does not converge for every symmetric positive-definite matrix. For example,
Examples
Example question
A linear system of the form
with initial estimate
is given by
![{\displaystyle A={\begin{bmatrix}2&1\\5&7\\\end{bmatrix}},\ b={\begin{bmatrix}11\\13\\\end{bmatrix}}\quad {\text{and}}\quad x^{(0)}={\begin{bmatrix}1\\1\\\end{bmatrix}}.}](https://wikimedia.org/api/rest_v1/media/math/render/svg/d99d9203a7aa825aeff53f7e0cbe0328ac9d56d2)
We use the equation
, described above, to estimate
. First, we rewrite the equation in a more convenient form
, where
and
. From the known values
we determine
as
Further,
is found as
With
and
calculated, we estimate
as
:
The next iteration yields
This process is repeated until convergence (i.e., until
is small). The solution after 25 iterations is
![{\displaystyle x={\begin{bmatrix}7.111\\-3.222\end{bmatrix}}.}](https://wikimedia.org/api/rest_v1/media/math/render/svg/5458d3839311975d33a349c54b41fbd82e3f7e98)
Example question 2
Suppose we are given the following linear system:
![{\displaystyle {\begin{aligned}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{aligned}}}](https://wikimedia.org/api/rest_v1/media/math/render/svg/11f2a2bb16c285c9e6adcb1581bfdb1dd3b84551)
If we choose (0, 0, 0, 0) as 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 five iterations.
| | | |
0.6 | 2.27272 | -1.1 | 1.875 |
1.04727 | 1.7159 | -0.80522 | 0.88522 |
0.93263 | 2.05330 | -1.0493 | 1.13088 |
1.01519 | 1.95369 | -0.9681 | 0.97384 |
0.98899 | 2.0114 | -1.0102 | 1.02135 |
The exact solution of the system is (1, 2, −1, 1).
Python example
import numpy as np
ITERATION_LIMIT = 1000
# initialize the matrix
A = np.array([[10., -1., 2., 0.],
[-1., 11., -1., 3.],
[2., -1., 10., -1.],
[0.0, 3., -1., 8.]])
# initialize the RHS vector
b = np.array([6., 25., -11., 15.])
# prints the system
print("System:")
for i in range(A.shape[0]):
row = [f"{A[i, j]}*x{j + 1}" for j in range(A.shape[1])]
print(f'{" + ".join(row)} = {b[i]}')
print()
x = np.zeros_like(b)
for it_count in range(ITERATION_LIMIT):
if it_count != 0:
print(f"Iteration {it_count}: {x}")
x_new = np.zeros_like(x)
for i in range(A.shape[0]):
s1 = np.dot(A[i, :i], x[:i])
s2 = np.dot(A[i, i + 1:], x[i + 1:])
x_new[i] = (b[i] - s1 - s2) / A[i, i]
if x_new[i] == x_new[i-1]:
break
if np.allclose(x, x_new, atol=1e-10, rtol=0.):
break
x = x_new
print("Solution: ")
print(x)
error = np.dot(A, x) - b
print("Error:")
print(error)
Weighted Jacobi method
The weighted Jacobi iteration uses a parameter
to compute the iteration as
![{\displaystyle \mathbf {x} ^{(k+1)}=\omega D^{-1}(\mathbf {b} -(L+U)\mathbf {x} ^{(k)})+\left(1-\omega \right)\mathbf {x} ^{(k)}}](https://wikimedia.org/api/rest_v1/media/math/render/svg/55781b3d1e705df6bcaa5d462d2f2fab12858414)
with
being the usual choice.[1] From the relation
, this may also be expressed as
.
Convergence in the symmetric positive definite case
In case that the system matrix
is of symmetric positive-definite type one can show convergence.
Let
be the iteration matrix. Then, convergence is guaranteed for
![{\displaystyle \rho (C_{\omega })<1\quad \Longleftrightarrow \quad 0<\omega <{\frac {2}{\lambda _{\text{max}}(D^{-1}A)}}\,,}](https://wikimedia.org/api/rest_v1/media/math/render/svg/015b64ccad791f1397250ffdac254c49fced516a)
where
is the maximal eigenvalue.
The spectral radius can be minimized for a particular choice of
as follows
where
is the matrix condition number.
See also
References
- ^ Saad, Yousef (2003). Iterative Methods for Sparse Linear Systems (2nd ed.). SIAM. p. 414. ISBN 0898715342.
External links
- This article incorporates text from the article Jacobi_method on CFD-Wiki that is under the GFDL license.
- Black, Noel; Moore, Shirley & Weisstein, Eric W. "Jacobi method". MathWorld.
- Jacobi Method from www.math-linux.com
Key concepts | |
---|
Problems | |
---|
Hardware | |
---|
Software | |
---|
Authority control databases: National ![Edit this at Wikidata](//upload.wikimedia.org/wikipedia/en/thumb/8/8a/OOjs_UI_icon_edit-ltr-progressive.svg/10px-OOjs_UI_icon_edit-ltr-progressive.svg.png) | |
---|