Jacobi method
From CFD-Wiki
Contents |
Introduction
We seek the solution to set of linear equations:
In matrix terms, the definition of the Jacobi method can be expressed as :
where , , and represent the diagonal, lower triangular, and upper triangular parts of the coefficient matrix and is the iteration count. This matrix expression is mainly of academic interest, and is not used to program the method. Rather, an element-based approach is used:
Note that the computation of requires each element in except itself. Then, unlike in the Gauss-Seidel method, we can't overwrite with , as that value will be needed by the rest of the computation. This is the most meaningful difference between the Jacobi and Gauss-Seidel methods. The minimum ammount of storage is two vectors of size , and explicit copying will need to take place.
Algorithm
Chose an initial guess to the solution
- for k := 1 step 1 untill convergence do
- for i := 1 step until n do
-
- for j := 1 step until n do
- if j != i then
- end if
- if j != i then
- end (j-loop)
-
- end (i-loop)
- check if convergence is reached
- for i := 1 step until n do
- end (k-loop)
Convergence
It is proven that if the absolute value of the diagonal term is always greater than the sum of the absolute values of other term in the row:
then the method always converge.
Usually, but not always, the method converges even if this condition is not satisfied, but the diagonal terms in the matrix are greater by the absolute values than the other terms.
Example Calculation
As with Gauss-Seidel, Jacobi iteration lends itself to situations in which we need not explicitly represent the matrix. Consider the simple heat equation problem
subject to the boundary conditions and . The exact solution to this problem is . The standard second-order finite difference discretization is
where is the (discrete) solution available at uniformly spaced nodes (see the Gauss-Seidel example for the matrix form). For any given for , we can write
Then, stepping through the solution vector from to , we can compute the next iterate from the two surrounding values. For a proper Jacobi iteration, we'll need to use values from the previous iteration on the right-hand side:
The following table gives the results of 10 iterations with 5 nodes (3 interior and 2 boundary) as well as norm error.
Iteration | error | |||||
---|---|---|---|---|---|---|
0 | 0.0000E+00 | 0.0000E+00 | 0.0000E+00 | 0.0000E+00 | 1.0000E+00 | 1.0000E+00 |
1 | 0.0000E+00 | 0.0000E+00 | 0.0000E+00 | 5.0000E-01 | 1.0000E+00 | 6.1237E-01 |
2 | 0.0000E+00 | 0.0000E+00 | 2.5000E-01 | 5.0000E-01 | 1.0000E+00 | 4.3301E-01 |
3 | 0.0000E+00 | 1.2500E-01 | 2.5000E-01 | 6.2500E-01 | 1.0000E+00 | 3.0619E-01 |
4 | 0.0000E+00 | 1.2500E-01 | 3.7500E-01 | 6.2500E-01 | 1.0000E+00 | 2.1651E-01 |
5 | 0.0000E+00 | 1.8750E-01 | 3.7500E-01 | 6.8750E-01 | 1.0000E+00 | 1.5309E-01 |
6 | 0.0000E+00 | 1.8750E-01 | 4.3750E-01 | 6.8750E-01 | 1.0000E+00 | 1.0825E-01 |
7 | 0.0000E+00 | 2.1875E-01 | 4.3750E-01 | 7.1875E-01 | 1.0000E+00 | 7.6547E-02 |
8 | 0.0000E+00 | 2.1875E-01 | 4.6875E-01 | 7.1875E-01 | 1.0000E+00 | 5.4127E-02 |
9 | 0.0000E+00 | 2.3438E-01 | 4.6875E-01 | 7.3438E-01 | 1.0000E+00 | 3.8273E-02 |
10 | 0.0000E+00 | 2.3438E-01 | 4.8438E-01 | 7.3438E-01 | 1.0000E+00 | 2.7063E-02 |