2 A five point stencil

The approach we shall use is to approximate the two second derivatives using central differences. First we need some notation for our numerical solution, and we shall re-use some of the ideas seen in HELM booklet  32.4 and HELM booklet  32.5. We divide the x -axis up into subintervals of width δ x and the y -axis into subintervals of width δ y .

There is a simplification available to us now that was not possible in HELM booklet  32. Here, the two independent variables ( x and y ) both measure distance (in HELM booklet  32 we had x measuring distance and t measuring time) and there is no reason to suppose that one direction is more important than another, so we may choose the subintervals δ x and δ y to be equal.

Key Point 4

In deriving numerical solutions to elliptic PDEs we use equal steps in the x and y directions. That is, we take

δ x = δ y = h (say)

So the idea is to approximate the second derivatives in the familiar way:

u x x u ( x + h , y ) 2 u ( x , y ) + u ( x h , y ) h 2 , u y y u ( x , y + h ) 2 u ( x , y ) + u ( x , y h ) h 2

We will write our numerical approximation as

u i , j u ( i h , j h ) ⏟ numerical exact (i.e. unknown) solution approximation evaluated at  x = i × h y = j × h

Key Point 5

We use subscripts on u to relate to space variables. For Elliptic PDEs both of the independent variables measure distance and so we have two subscripts.

Key Point 6

If there is no danger of ambiguity we may omit the comma from the subscript. That is,

u i , j     may be written    u i j    and    f i , j   may be written   f i j

Given all of this preamble we can now write down a difference equation which approximates the partial differential equation:

u i + 1 , j 2 u i , j + u i 1 , j h 2 ⏟ + u i , j + 1 2 u i , j + u i , j 1 h 2 ⏟ = f i , j u x x u y y notation for  f ( i h , j h )

Rearranging this gives

4 u i , j + u i + 1 , j + u i 1 , j + u i , j + 1 + u i , j 1 = h 2 f i , j

This equation defines a five-point stencil approximating the PDE. The following diagram shows the stencil.

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

The idea in an implementation of this stencil is to centre the cross-shape on each i , j node where we want to find u . This guarantees that we will end up with the same number of equations as unknowns. An example of this approach will follow shortly, but first we note other ways of writing down the five-point stencil.

As the diagram above shows, the stencil involves a centre point and four additional points each corresponding to one of the points of the compass. It is this observation which has led to a simplified version of the mathematical expression and the diagram. The symbolic stencil can be written

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

where a subscript 0 corresponds to the centre of the stencil and other subscripts correspond to compass points (North, South, East, West) in the obvious way. The diagram becomes

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

and we reinterpret the local “ 0 , N , S , E , W " positions each time we move the stencil on the global grid.

Another way of writing the stencil is as follows:

1 1 4 1 1

This latest version has the advantage of showing the values of the coefficients used in approximating u x x + u y y .

We summarise in Key Point 7 the main idea using the notation established above.

Key Point 7

The five-point stencil used to approximate the partial differential equation

u x x + u y y = f ( x , y )

gives rise to the difference equation

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

Example 6

Consider the boundary value problem

u x x + u y y = 0 in the square 0 < x < 1 , 0 < y < 1

u = x 2 y   on the boundary.

Use h = 1 3 and formulate a system of simultaneous equations for the 4 unknowns.

Solution

In the diagram on the right we see a schematic of the square in the x y plane. The numbers correspond to boundary data where the numerical grid intersects that boundary. The (as yet unknown) numerical approximations are shown in the positions where they approximate u ( x , y ) .

y 0 1 9 4 9 1 0 u 12 u 22 2 3 0 u 11 u 21 1 3 0 0 0 0 x

The numerical stencil in this case is 4 u 0 + u E + u W + u N + u S = 0 and we centre this at each of the places where u is sought. There are four such places in this example:

bottom left: 4 u 11 + u 21 + 0 + u 12 + 0 = 0 bottom right: 4 u 21 + 1 3 + u 11 + u 22 + 0 = 0 top left: 4 u 12 + u 22 + 0 + 1 9 + u 11 = 0 top right: 4 u 22 + 2 3 + u 12 + 4 9 + u 21 = 0 Centre East West North South

This is a system of equations in the four unknowns which may be written

4 1 1 0 1 4 0 1 1 0 4 1 0 1 1 4 u 11 u 21 u 12 u 22 = 0 1 3 1 9 10 9

It is now a (simple, in theory) matter of solving the system to obtain the numerical approximation to u . It turns out that the solution to the system of equations is u 11 = 1 12 , u 21 = 7 36 , u 12 = 5 36 and u 22 = 13 36 . These values are, to four decimal places, 0.0833, 0.1944, 0.1389 and 0.3611, respectively.

We will say more later about how to solve the system of equations, but first there is a Task to help consolidate what we have covered so far.

Task!

Consider the boundary value problem

u x x + u y y = 2 in the square  0 < x < 1 , 0 < y < 1 u = x y on the boundary .

Use h = 1 3 and hence formulate a system of simultaneous equations for the four unknowns.

In the diagram on the right we see a schematic of the square in the x y plane. The numbers correspond to boundary data where the numerical grid intersects that boundary. The (as yet unknown) numerical approximations are shown in the positions where they approximate u ( x , y ) .

y 0 1 3 2 3 1 0 u 12 u 22 2 3 0 u 11 u 21 1 3 0 0 0 0 x

The numerical stencil in this case is

4 u 0 + u E + u W + u N + u S = h 2 f 0 = ( 1 3 ) 2 × ( 2 ) = 2 9

and we centre this at each of the places where u is sought. In this Example there are four such places:

bottom left: 4 u 11 + u 21 + 0 + u 12 + 0 = 2 9 bottom right: 4 u 21 + 1 3 + u 11 + u 22 + 0 = 2 9 top left: 4 u 12 + u 22 + 0 + 1 3 + u 11 = 2 9 top right: 4 u 22 + 2 3 + u 12 + 2 3 + u 21 = 2 9 Centre East West North South

This is a system of equations in the four unknowns and it may be written

4 1 1 0 1 4 0 1 1 0 4 1 0 1 1 4 u 11 u 21 u 12 u 22 = 2 9 5 9 5 9 14 9