Jacobi method

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search

In numerical linear algebra, the Jacobi 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[edit]

Let

be a square system of n linear equations, where:

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

where is the kth approximation or iteration of and is the next or k + 1 iteration of . The element-based formula is thus:

The computation of requires each element in x(k) 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[edit]

Input: initial guess  to the solution, (diagonal dominant) matrix , right-hand side vector , convergence criterion
Output: solution when convergence is reached
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
    
end

Convergence[edit]

The standard convergence condition (for any iterative method) is when the spectral radius of the iteration matrix is less than 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:

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

Example[edit]

A linear system of the form with initial estimate is given by

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

Another example[edit]

Suppose we are given the following linear system:

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).

An example using Python and Numpy[edit]

The following numerical procedure simply iterates to produce the solution vector.

def jacobi(A, b, x_init, epsilon=1e-10, max_iterations=500):
    D = np.diag(np.diag(A))
    LU = A - D
    x = x_init
    for i in range(max_iterations):
        D_inv = np.diag(1 / np.diag(D))
        x_new = np.dot(D_inv, b - np.dot(LU, x))
        if np.linalg.norm(x_new - x) < epsilon:
            return x_new
        x = x_new
    return x

# problem data
A = np.array([
    [5, 2, 1, 1],
    [2, 6, 2, 1],
    [1, 2, 7, 1],
    [1, 1, 2, 8]
])
b = np.array([29, 31, 26, 19])

# you can choose any starting vector
x_init = np.zeros(len(b))
x = jacobi(A, b, x_init)

print('x:', x)
print('computed b:', np.dot(A, x))
print('real b:', b)

Produces the output:

x: [3.99275362 2.95410628 2.16183575 0.96618357]
computed b: [29. 31. 26. 19.]
real b: [29 31 26 19]

Weighted Jacobi method[edit]

The weighted Jacobi iteration uses a parameter to compute the iteration as

with being the usual choice.[1]

Convergence in the symmetric positive definite case[edit]

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

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[edit]

References[edit]

  1. ^ Saad, Yousef (2003). Iterative Methods for Sparse Linear Systems (2 ed.). SIAM. p. 414. ISBN 0898715342.

External links[edit]