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.
Let
Ax=b
When
A
b
x
x
x(0)
x
(0) | |
x | |
i=0 |
i=1,2,...,n
x(k)
x
x(k+1)
x
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
x(k+1)=D-1(b-(L+U)x(k)).
The element-based formula for each row
i
(k+1) | |
x | |
i |
x(k)
(k) | |
x | |
i |
(k+1) | |
x | |
i |
Input:, (diagonal dominant) matrix A, right-hand side vector b, convergence criterion Output: Comments: pseudocode based on the element-based formula above while convergence not reached do for i := 1 step until n do for j := 1 step until n do if j ≠ i then end end end increment k end
The standard convergence condition (for any iterative method) is when the spectral radius of the iteration matrix is less than 1:
\rho(D-1(L+U))<1.
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:
\left|aii\right|>\sumj{\left|aij\right|}.
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,
A linear system of the form
Ax=b
x(0)
A= \begin{bmatrix} 2&1\\ 5&7\\ \end{bmatrix}, b= \begin{bmatrix} 11\\ 13\\ \end{bmatrix} and x(0)= \begin{bmatrix} 1\\ 1\\ \end{bmatrix}.
x(k+1)=D-1(b-(L+U)x(k))
x
D-1(b-(L+U)x(k))=Tx(k)+C
T=-D-1(L+U)
C=D-1b
T=-D-1(L+U)
C
T
C
x
x(1)=Tx(0)+C
\|Ax(n)-b\|
x=\begin{bmatrix} 7.111\\ -3.222 \end{bmatrix} .
Suppose we are given the following linear system:
\begin{align} 10x1-x2+2x3&=6,\\ -x1+11x2-x3+3x4&=25,\\ 2x1-x2+10x3-x4&=-11,\\ 3x2-x3+8x4&=15. \end{align}
If we choose as the initial approximation, then the first approximate solution is given byUsing the approximations obtained, the iterative procedure is repeated until the desired accuracy has been reached. The following are the approximated solutions after five iterations.
x1 | x2 | x3 | x4 | |
---|---|---|---|---|
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 |
ITERATION_LIMIT = 1000
A = np.array(10., -1., 2., 0., [-1., 11., -1., 3.], [2., -1., 10., -1.], [0.0, 3., -1., 8.]])
b = np.array([6., 25., -11., 15.])
print("System:")for i in range(A.shape[0]): row = [f"{A[i, j]}*x" for j in range(A.shape[1])] print(f' = ')print
x = np.zeros_like(b)for it_count in range(ITERATION_LIMIT): if it_count != 0: print(f"Iteration : ") 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]
if np.allclose(x, x_new, atol=1e-10, rtol=0.): break
x = x_new
print("Solution: ")print(x)error = np.dot(A, x) - bprint("Error:")print(error)
The weighted Jacobi iteration uses a parameter
\omega
x(k+1)=\omegaD-1(b-(L+U)x(k))+\left(1-\omega\right)x(k)
\omega=2/3
L+U=A-D
x(k+1)=\omegaD-1b+\left(I-\omegaD-1A\right)x(k)
In case that the system matrix
A
Let
C=C\omega=I-\omegaD-1A
\rho(C\omega)<1 \Longleftrightarrow 0<\omega<
2 | |
λmax(D-1A) |
,
λmax
The spectral radius can be minimized for a particular choice of
\omega=\omegaopt
\kappa