HOME

TheInfoList



OR:

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 In mathematics, a system of linear equations (or linear system) is a collection of two or more linear equations involving the same variable (math), variables. For example, : \begin 3x+2y-z=1\\ 2x-2y+4z=-2\\ -x+\fracy-z=0 \end is a system of th ...
. 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 A\mathbf x = \mathbf b be a square system of ''n'' linear equations, where:A = \begin a_ & a_ & \cdots & a_ \\ a_ & a_ & \cdots & a_ \\ \vdots & \vdots & \ddots & \vdots \\a_ & a_ & \cdots & a_ \end, \qquad \mathbf = \begin x_ \\ x_2 \\ \vdots \\ x_n \end , \qquad \mathbf = \begin b_ \\ b_2 \\ \vdots \\ b_n \end. When A and \mathbf b are known, and \mathbf x is unknown, we can use the Jacobi method to approximate \mathbf x. The vector \mathbf x^ denotes our initial guess for \mathbf x (often \mathbf x^_i=0 for i=1,2,...,n). We denote \mathbf^ as the ''k-''th approximation or iteration of \mathbf, and \mathbf^ is the next (or ''k''+1) iteration of \mathbf.


Matrix-based formula

Then ''A'' can be decomposed into a
diagonal In geometry, a diagonal is a line segment joining two vertices of a polygon or polyhedron, when those vertices are not on the same edge. Informally, any sloping line is called diagonal. The word ''diagonal'' derives from the ancient Greek � ...
component ''D'', a lower triangular part ''L'' and an upper triangular part ''U'':A=D+L+U \qquad \text \qquad D = \begin a_ & 0 & \cdots & 0 \\ 0 & a_ & \cdots & 0 \\ \vdots & \vdots & \ddots & \vdots \\0 & 0 & \cdots & a_ \end \text L+U = \begin 0 & a_ & \cdots & a_ \\ a_ & 0 & \cdots & a_ \\ \vdots & \vdots & \ddots & \vdots \\ a_ & a_ & \cdots & 0 \end. The solution is then obtained iteratively via : \mathbf^ = D^ (\mathbf - (L+U) \mathbf^).


Element-based formula

The element-based formula for each row i is thus: x^_i = \frac \left(b_i -\sum_a_x^_j\right),\quad i=1,2,\ldots,n. The computation of x_i^ requires each element in \mathbf^ except itself. Unlike the Gauss–Seidel method, we cannot overwrite x_i^ with x_i^, 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: , (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


Convergence

The standard convergence condition (for any iterative method) is when the
spectral radius ''Spectral'' is a 2016 Hungarian-American military science fiction action film co-written and directed by Nic Mathieu. Written with Ian Fried (screenwriter), Ian Fried & George Nolfi, the film stars James Badge Dale as DARPA research scientist Ma ...
of the iteration matrix is less than 1: :\rho(D^(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 , a_ \right , > \sum_ . 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 = \begin 29 & 2 & 1\\ 2 & 6 & 1\\ 1 & 1 & \frac \end \quad \Rightarrow \quad D^ (L+U) = \begin 0 & \frac & \frac\\ \frac & 0 & \frac\\ 5 & 5 & 0 \end \quad \Rightarrow \quad \rho(D^(L+U)) \approx 1.0661 \,.


Examples


Example question

A linear system of the form Ax=b with initial estimate x^ is given by : A= \begin 2 & 1 \\ 5 & 7 \\ \end, \ b= \begin 11 \\ 13 \\ \end \quad \text \quad x^ = \begin 1 \\ 1 \\ \end . We use the equation x^=D^(b - (L+U)x^), described above, to estimate x. First, we rewrite the equation in a more convenient form D^(b - (L+U)x^) = Tx^ + C, where T=-D^(L+U) and C = D^b. From the known values D^= \begin 1/2 & 0 \\ 0 & 1/7 \\ \end, \ L= \begin 0 & 0 \\ 5 & 0 \\ \end \quad \text \quad U = \begin 0 & 1 \\ 0 & 0 \\ \end . we determine T=-D^(L+U) as T= \begin 1/2 & 0 \\ 0 & 1/7 \\ \end \left\ = \begin 0 & -1/2 \\ -5/7 & 0 \\ \end . Further, C is found as C = \begin 1/2 & 0 \\ 0 & 1/7 \\ \end \begin 11 \\ 13 \\ \end = \begin 11/2 \\ 13/7 \\ \end. With T and C calculated, we estimate x as x^= Tx^+C : x^= \begin 0 & -1/2 \\ -5/7 & 0 \\ \end \begin 1 \\ 1 \\ \end + \begin 11/2 \\ 13/7 \\ \end = \begin 5.0 \\ 8/7 \\ \end \approx \begin 5 \\ 1.143 \\ \end . The next iteration yields x^= \begin 0 & -1/2 \\ -5/7 & 0 \\ \end \begin 5.0 \\ 8/7 \\ \end + \begin 11/2 \\ 13/7 \\ \end = \begin 69/14 \\ -12/7 \\ \end \approx \begin 4.929 \\ -1.714 \\ \end . This process is repeated until convergence (i.e., until \, Ax^ - b\, is small). The solution after 25 iterations is : x=\begin 7.111\\ -3.222 \end .


Example question 2

Suppose we are given the following linear system: : \begin 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 If we choose as the initial approximation, then the first approximate solution is given by \begin x_1 & = (6 + 0 - (2 * 0)) / 10 = 0.6, \\ x_2 & = (25 + 0 + 0 - (3 * 0)) / 11 = 25/11 = 2.2727, \\ x_3 & = (-11 - (2 * 0) + 0 + 0) / 10 = -1.1,\\ x_4 & = (15 - (3 * 0) + 0) / 8 = 1.875. \end 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. The exact solution of the system is .


Python example

import numpy as np ITERATION_LIMIT = 1000 # initialize the matrix A = np.array( 10., -1., 2., 0. 1., 11., -1., 3. ., -1., 10., -1. .0, 3., -1., 8.) # initialize the RHS vector b = np.array( ., 25., -11., 15. # prints the system print("System:") for i in range(A.shape : row = "*x" for j in range(A.shape[1">.html" ;"title=""*x" for j in range(A.shape[1">"*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 : 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 \omega to compute the iteration as : \mathbf^ = \omega D^ (\mathbf - (L+U) \mathbf^) + \left(1-\omega\right)\mathbf^ with \omega = 2/3 being the usual choice. From the relation L + U = A - D , this may also be expressed as : \mathbf^ = \omega D^ \mathbf + \left( I - \omega D^ A \right) \mathbf^ .


Convergence in the symmetric positive definite case

In case that the system matrix A is of symmetric positive-definite type one can show convergence. Let C=C_\omega = I-\omega D^A be the iteration matrix. Then, convergence is guaranteed for : \rho(C_\omega) < 1 \quad \Longleftrightarrow \quad 0 < \omega < \frac \,, where \lambda_\text is the maximal eigenvalue. The spectral radius can be minimized for a particular choice of \omega = \omega_\text as follows \min_\omega \rho (C_\omega) = \rho (C_) = 1-\frac \quad \text \quad \omega_\text := \frac \,, where \kappa is the matrix condition number.


See also

* Gauss–Seidel method * Successive over-relaxation * Iterative method § Linear systems * Gaussian Belief Propagation * Matrix splitting


References


External links

* *
Jacobi Method from www.math-linux.com
{{Authority control Numerical linear algebra Articles with example pseudocode Relaxation (iterative methods) Articles with example Python (programming language) code