4 Iterative methods

An implementation of the five-point stencil

4 u 0 + u E + u W + u S + u N = h 2 f 0

leads to a system of simultaneous equations in the unknowns. This system of equations can be dealt with using methods seen in HELM booklet  30, but here we show ways in which systematic iterative methods can be derived directly from the numerical stencil .

The general approach is as follows:

  1. Start with an initial guess for the unknowns. Call this initial guess u i , j 0 .
  2. Use some means to improve the guess. Call the improvement u i , j 1 .
  3. And so on. In general we derive a new set of approximations u i , j n + 1 in terms of the previous approximations u i , j n .

4.1 Jacobi iteration

The approach we adopt here is to update the approximation at the centre of the stencil using the four old values around the edge of the stencil. That is

4 u 0 n + 1 + u E n + u W n + u S n + u N n = h 2 f 0

rearranging this gives

u 0 n + 1 = 1 4 u E n + u W n + u S n + u N n h 2 f 0

The following Example uses the same data (rounded to four decimal places here) as in Example 6.

Example 7

Suppose that u = u ( x , y ) satisfies Laplace’s equation

u x x + u y y = 0

in the square region 0 < x , y < 1 with u = x 2 y on the boundary. Assuming a mesh size of h = 1 3 use the Jacobi iteration, with starting values u i j 0 = 0 , to perform two iterations. The boundary data are as given in the schematic below.

y 0.0000 0.1111 0.4444 1.0000 0.0000 u 12 u 22 0.6667 0.0000 u 11 u 21 0.3333 0.0000 0.0000 0.0000 0.0000 x

Solution

Putting in the initial guesses for the four unknowns u 11 , u 12 , u 21 , u 22 we obtain the situation depicted below.

y 0.0000 0.1111 0.4444 1.0000 0.0000 0 0 0.6667 0.0000 0 0 0.3333 0.0000 0.0000 0.0000 0.0000 x

The first iteration involves using

4 u 0 1 = u E 0 + u W 0 + u N 0 + u S 0 h 2 f 0

where, in this case, h 2 f 0 = 0 . So the first iteration gives us

u 11 1 = 0.0000 u 21 1 = 0.0833 u 12 1 = 0.0278 u 22 1 = 0.2778

The second iteration begins by putting these new approximations to the interior values into the grid. This gives

y 0.0000 0.1111 0.4444 1.0000 0.0000 0.0278 0.2778 0.6667 0.0000 0.0000 0.0833 0.3333 0.0000 0.0000 0.0000 0.0000 x

We now apply 4 u 0 2 = u E 1 + u W 1 + u N 1 + u S 1 to obtain

u 11 2 = 0.0278 u 21 2 = 0.1528 u 12 2 = 0.0972 u 22 2 = 0.3056

In practice, using a computer to carry out the arithmetic, we would continue iterating until the results settle down to a converged value. Using a computer spreadsheet, for example, we can see that a total of 15 iterations is enough to achieve results converged to four decimal places. We noted earlier that, to four decimal places, u 11 = 0.0833 , u 21 = 0.1944 , u 12 = 0.1389 and u 22 = 0.3611 .

The following Task uses the same data as the preceding Task (pages 23-24), except that we have rounded the boundary data to four decimal places instead of using the exact fractions.

Task!

Suppose that u = u ( x , y ) satisfies Poisson’s equation

u x x + u y y = 2

in the square region 0 < x , y < 1 with u = x y on the boundary. Assuming a mesh size of h = 1 3 use the Jacobi iteration, with starting values u i j 0 = 0 , to perform two iterations. The boundary data are as given in the schematic below.

y 0.0000 0.3333 0.6667 1.0000 0.0000 u 12 u 22 0.6667 0.0000 u 11 u 21 0.3333 0.0000 0.0000 0.0000 0.0000 x

Putting in the initial guesses for the four unknowns we obtain the situation depicted below.

y 0.0000 0.3333 0.6667 1.0000 0.0000 0 0 0.6667 0.0000 0 0 0.3333 0.0000 0.0000 0.0000 0.0000 x

The first iteration involves using

4 u 0 1 = u E 0 + u W 0 + u N 0 + u S 0 h 2 f 0

where in this case h 2 f 0 = 0.2222 . So the first iteration gives us

u 11 1 = 0.0556 u 21 1 = 0.1389 u 12 1 = 0.1389 u 22 1 = 0.3889

The second iteration begins by putting these new approximations to the interior values into the grid. This gives

y 0.0000 0.3333 0.6667 1.0000 0.0000 0.1389 0.3889 0.6667 0.0000 0.0556 0.1389 0.3333 0.0000 0.0000 0.0000 0.0000 x

We now perform the second iteration 4 u 0 2 = u E 1 + u W 1 + u N 1 + u S 1 h 2 f 0 again, but with the new values. We obtain

u 11 2 = 0.1250 u 21 2 = 0.2500 u 12 2 = 0.2500 u 22 2 = 0.4583

In the case above 17 iterations are required to achieve results that have converged to 4 decimal places. We find that u 11 = 0.2222 , u 12 = 0.3333 , u 21 = 0.3333 and u 22 = 0.5556 .

4.2 Gauss-Seidel iteration

In the implementation of the Jacobi method we used old values for the southerly and westerly points when new values had already been calculated.

No alt text was set. Please request alt text from the person who provided you with this resource.

The Gauss-Seidel method uses the new values as soon as they are available. Stating this formally we have

new values here u 0 n + 1 = 1 4 u E n + u W n + 1 + u S n + 1 + u N n h 2 f 0

Example 8 below uses the same data as Examples 6 and 7.

Example 8

Suppose that u = u ( x , y ) satisfies Laplace’s equation

u x x + u y y = 0

in the square region 0 < x , y < 1 with u = x 2 y on the boundary. Assuming a mesh size of h = 1 3 , use the Gauss-Seidel iteration, with starting values u i j 0 = 0 , to perform two iterations. The boundary data are as given in the schematic below.

y 0.0000 0.1111 0.4444 1.0000 0.0000 u 12 u 22 0.6667 0.0000 u 11 u 21 0.3333 0.0000 0.0000 0.0000 0.0000 x

Solution

Putting in the initial guesses for the four unknowns we obtain the situation depicted below.

y 0.0000 0.1111 0.4444 1.0000 0.0000 0 0 0.6667 0.0000 0 0 0.3333 0.0000 0.0000 0.0000 0.0000 x

The first iteration involves using

4 u 0 1 = u E 0 + u W 1 + u N 0 + u S 1 h 2 f 0

where in this case h 2 f 0 = 0 . So the first iteration gives us

u 11 1 = 0.0000 u 21 1 = 0.0833 u 12 1 = 0.0278 u 22 1 = 0.3056

The second iteration begins by putting these new approximations to the interior values into the grid. This gives

y 0.0000 0.1111 0.4444 1.0000 0.0000 0.0278 0.3056 0.6667 0.0000 0.0000 0.0833 0.3333 0.0000 0.0000 0.0000 0.0000 x

We now apply 4 u 0 2 = u E 1 + u W 2 + u N 1 + u S 2 h 2 f 0 to obtain

u 11 2 = 0.0278 u 21 2 = 0.1667 u 12 2 = 0.1111 u 22 2 = 0.3472

(And, using a computer spreadsheet, for example, we can see that a total of 7 iterations is enough to achieve results converged to four decimal places. This compares well with the 15 iterations required by Jacobi in Example 7.)

Task!

Suppose that u = u ( x , y ) satisfies Poisson’s equation

u x x + u y y = 2

in the square region 0 < x , y < 1 with u = x y on the boundary. Assuming a mesh size of h = 1 3 use the Gauss-Seidel iteration, with starting values u i j 0 = 0 , to perform two iterations. The boundary data are as given in the schematic below.

y 0.0000 0.3333 0.6667 1.0000 0.0000 u 12 u 22 0.6667 0.0000 u 11 u 21 0.3333 0.0000 0.0000 0.0000 0.0000 x

Putting in the initial guesses for the four unknowns we obtain the situation depicted below.

y 0.0000 0.3333 0.6667 1.0000 0.0000 0 0 0.6667 0.0000 0 0 0.3333 0.0000 0.0000 0.0000 0.0000 x

The first iteration involves using

4 u 0 1 = u E 0 + u W 1 + u N 0 + u S 1 h 2 f 0

where in this case h 2 f 0 = 0.2222 . We need to take care so as to use new values as soon as they are available So the first iteration gives us

u 11 1 = 0.0556 u 21 1 = 0.1528 using the new  u 11  approximation u 12 1 = 0.1528 using the new  u 11  approximation u 22 1 = 0.4653 using the new  u 12  and  u 21  approximations                              

(to 4 decimal places).

The second iteration begins by putting these new approximations to the interior values into the grid. This gives

y 0.0000 0.3333 0.6667 1.0000 0.0000 0.1528 0.4653 0.6667 0.0000 0.0556 0.1528 0.3333 0.0000 0.0000 0.0000 0.0000 x

We now apply 4 u 0 2 = u E 1 + u W 2 + u N 1 + u S 2 h 2 f 0 again, but with the new values. We obtain

u 11 2 = 0.1319 u 21 2 = 0.2882 using the new  u 11  approximation u 12 2 = 0.2882 using the new  u 11  approximation u 22 2 = 0.5330 using the new  u 12  and  u 21  approximations                              

and we can write this information in the form

y 0.0000 0.3333 0.6667 1.0000 0.0000 0.2882 0.5330 0.6667 0.0000 0.1319 0.2882 0.3333 0.0000 0.0000 0.0000 0.0000 x

Again, a computer can be used to continue iterating until convergence. This method applied to this Task needs 8 iterations to achieve 4 decimal place convergence, a fact which compares very well with the 17 required by the Jacobi method.

4.3 Convergence

We now summarise some important points

  1. For the problems discussed in these pages, the Jacobi and Gauss-Seidel methods will always converge for any initial guesses u i j 0 . (Of course, very poor initial guesses will result in more iterations being required.)
  2. For a given problem and given starting guesses u i j 0 , the Gauss-Seidel method will, in general, converge in fewer iterations than Jacobi . (That is, using the new, improved values as soon as they are available speeds up the process.)
  3. One possible advantage with the Jacobi approach is that it can be parallelised , that is, it is in theory possible to do all the calculations for a given iteration simultaneously. In other words, everything we will need to know to carry out an iteration is known before the iteration begins. This is not the case with Gauss-Seidel in which during an iteration, most calculations use a result from within the current iteration. This advantage with Jacobi only manifests itself when using computers with a parallelisation option and for large problems.
Exercises
  1. Suppose that u = u ( x , y ) satisfies Laplace’s equation

    u x x + u y y = 0

    in the square region 0 < x , y < 1 . Assuming a mesh size of h = 1 3 use the Jacobi iteration, with starting values u i j 0 = 0 , to perform two iterations. The boundary data are as given in the schematic below:

    y 0.0000 0.2500 0.7500 1.0000 0.4000 u 12 u 22 0.8000 0.8000 u 11 u 21 0.4000 0.0000 0.7500 0.2500 0.0000 x

  2. Suppose that u = u ( x , y ) satisfies Laplace’s equation

    u x x + u y y = 0

    in the square region 0 < x , y < 1 . Assuming a mesh size of h = 1 3 use the Gauss-Seidel iteration, with starting values u i j 0 = 0 , to perform two iterations. The boundary data are as given in the schematic below.

    y 0.0000 0.2500 0.7500 1.0000 0.4000 u 12 u 22 0.8000 0.8000 u 11 u 21 0.4000 0.0000 0.7500 0.2500 0.0000 x

  1. Putting in the initial guesses for the four unknowns we obtain the situation depicted below.

    y 0.0000 0.2500 0.7500 1.0000 0.4000 0 0 0.8000 0.8000 0 0 0.4000 0.0000 0.7500 0.2500 0.0000 x

    The first iteration involves using

    4 u 0 1 = u E 0 + u W 0 + u N 0 + u S 0 h 2 f 0

    where in this case h 2 f 0 = 0.0000 . So the first iteration gives us

    u 11 1 = 0.3875 u 21 1 = 0.1625 u 12 1 = 0.1625 u 22 1 = 0.3875

    The second iteration begins by putting these new approximations to the interior values into the grid. This gives

    y 0.0000 0.2500 0.7500 1.0000 0.4000 0.1625 0.3875 0.8000 0.8000 0.3875 0.1625 0.4000 0.0000 0.7500 0.2500 0.0000 x

    We now apply 4 u 0 2 = u E 1 + u W 1 + u N 1 + u S 1 h 2 f 0 to obtain

    u 11 2 = 0.4688 u 21 2 = 0.3563 u 12 2 = 0.3563 u 22 2 = 0.4688
  2. Putting in the initial guesses for the four unknowns we obtain the situation depicted below.

    y 0.0000 0.2500 0.7500 1.0000 0.4000 0 0 0.8000 0.8000 0 0 0.4000 0.0000 0.7500 0.2500 0.0000 x

    The first iteration involves using

    4 u 0 1 = u E 0 + u W 1 + u N 0 + u S 1 h 2 f 0

    where in this case h 2 f 0 = 0.0000 . So the first iteration gives us

    u 11 1 = 0.3875 u 21 1 = 0.2594 u 12 1 = 0.2594 u 22 1 = 0.5172

    The second iteration begins by putting these new approximations to the interior values into the grid. This gives

    y 0.0000 0.2500 0.7500 1.0000 0.4000 0.2594 0.5172 0.8000 0.8000 0.3875 0.2594 0.4000 0.0000 0.7500 0.2500 0.0000 x

    We now apply 4 u 0 2 = u E 1 + u W 2 + u N 1 + u S 2 h 2 f 0 to obtain

    u 11 2 = 0.5172 u 21 2 = 0.4211 u 12 2 = 0.4211 u 22 2 = 0.5980