Numerical Solutions to PDE
Numerical Solutions to PDE
Introduction:
The partial differential equation (PDE) is one of the most important and useful
topics of mathematics, physics and different branches of engineering. But, finding of
solution of PDEs is a very difficult task. Several analytical methods are available to
solve PDEs, but, all these methods need in depth mathematical knowledge. On the
other hand numerical methods are simple, but generate erroneous result. Most widely
used numerical method is finite-difference method due to its simplicity. In this module,
only finite-difference method is discussed to solve PDEs.
∆ = B 2 − 4AC.
The PDE of equation (1.2) is called elliptic, parabolic and hyperbolic according as
the value of ∆ at any point (x, y) is < 0, = 0 or > 0.
Elliptic equation
The most simple examples of this type of PDEs are Poisson’s equation
∂2u ∂2u
+ 2 = g(x, y) (1.3)
∂x2 ∂y
and Laplace equation
∂2u ∂2u
+ 2 =0 or ∇2 u = 0. (1.4)
∂x2 ∂y
The analytic solution of an elliptic equation is a function of x and y which satisfies
the PDE at every point of the region S which is bounded by a plane closed curve C
and satisfies some conditions at every point on C. The condition that the dependent
variable satisfies along the boundary curve C is known as boundary condition.
1
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Partial Differential Equation: Parabolic
Parabolic equation
Hyperbolic equation
The third type PDE is hyperbolic. Also, in this equation time t is taken as an indepen-
dent variable.
The simplest example of hyperbolic equation is the one-dimensional wave equation
∂2u 2
2∂ u
= c . (1.6)
∂t2 ∂x2
Let x and y be two independent variables and u be the dependent variable of the
given PDE. Now, we divide the xy-plane into set of equal rectangles of lengths ∆x = h
and ∆y = k by drawing the equally spaced grid lines parallel to the coordinates axes.
That is,
The intersection of horizontal and vertical lines is called mesh point and the ijth
mesh point is denoted by P (xi , yj ) or P (ih, jk). The value of u at this mesh point is
denoted by ui,j , i.e. ui,j = u(xi , yj ) = u(ih, jk).
The first order partial derivatives at this mesh point are approximated as follows:
ui+1,j − ui,j
ux (ih, jk) = + O(h) (1.7)
h
(forward difference approximation)
ui,j − ui−1,j
= + O(h) (1.8)
h
(backward difference approximation)
ui+1,j − ui−1,j
= + O(h2 ) (1.9)
2h
(central difference approximation)
with the initial condition u(x, 0) = f (x) and the boundary conditions u(0, t) = φ(t), u(1, t) =
ψ(t).
where r = αk/h2 .
From this formula one can compute the value of ui,j+1 at the mesh point (i, j + 1)
when the values of ui−1,j , ui,j and ui+1,j are known. So this method is called the explicit
method. By stability analysis, it can be shown that the formula is stable, if 0 < r ≤ 1/2.
The grids and mesh points are shown in Figure 1.1. For this problem, the initial and
boundary values are given. These values are shown in the figure by filled circles. That
is, the values of u are known along x-axis and two vertical lines (t = 0 and t = 1). Also,
it is mentioned in the figure that if the values at the meshes (i − 1, j), (i, j) and (i + 1, j)
are known (shown by filled circles) then one can determine the value of u for the mesh
(i, j + 1) (shown by circle).
subject to the boundary conditions u(0, t) = 0, u(1, t) = 3t and initial condition u(x, 0) =
1.5x.
Solution. Let h = 0.2 and k = 0.01, so r = k/h2 = 0.25 < 1/2. The initial and
boundary values are shown in the following table.
4
......................................................................................
t 6
u u
u u
u known values
u e u
ui,j+1 ⊕ unknown value
u u u u u
ui−1,j ui,j ui+1,j
u u
6
k h-
u? u u u u u u- x
t = 0, u = f (x)
The values of u for all meshes are shown in the following table.
The above explicit method is very simple and it has limitation. This method is
stable if 0 < r ≤ 1/2, i.e. 0 < αk/h2 ≤ 1/2, or αk ≤ h2 /2. That is, the value of k
must be chosen very small, and it takes time to get the result at a particular mesh. In
1947, Crank and Nicolson have developed an implicit method which reduces the total
computation time. Also, the method is applicable for all finite values of r. In this
method, the given PDE is approximated by replacing both space and time derivatives
by their central difference approximations at the midpoint of the points (ih, jk) and
(ih, (j + 1)k), i.e. at the point (ih, (j + 1/2)k). To use approximation at this point, we
write the equation (1.15) in the following form
2
α ∂2u
2
∂u ∂ u ∂ u
=α = + . (1.18)
∂t i,j+1/2 ∂x2 i,j+1/2 2 ∂x2 i,j ∂x2 i,j+1
In general, the left hand side of the above equation contains three unknowns values,
but the right hand side has three known values of u.
The known (circle) and unknown (filled circle) meshes are shown in Figure 1.2.
t
6
u u
u e e e u
j+1
u e
u u u u ⊕ unknown values
j u known values
u u
u u u u u u u- x
i=0 i−1 i i+1 i=N
In this method, the value of ui,j+1 is not expressed directly in terms of known values
of u’s obtained in earlier step, it is written as unknown values, and hence the method
is implicit.
The system of equations (1.19) for a fixed j, can be expressed as the following matrix
notation.
7
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Partial Differential Equation: Parabolic
2+2r −r u1,j+1 d1,j
u2,j+1 d2,j
−r 2+2r −r
· · · · · · · · · · · · · · · · · · · · · u3,j+1 = d3,j (1.20)
.. ..
−r 2+2r −r
.
.
−r 2+2r uN −1,j+1 dN −1,j
where
1
Example 1.2 Solve the following problem by Crank-Nicolson method by taking h =
4
1 1
and k = ,
8 16
∂u ∂2u
= , 0 < x < 1, t > 0
∂t ∂x2
where u(0, t) = u(1, t) = 0, t > 0, u(x, 0) = 3x, t = 0.
Solution. Case I.
1 1 k
Let h = and k = . Therefore, r = 2 = 2.
4 8 h
The Crank-Nicolson scheme is
t
6u0,1 u1,1 u2,1 u3,1 u4,1
j=1, t= 81 u e e e u
A B C
u0,0 u1,0 u2,0 u3,0 u
j=0, t=0 u u u u u-4,0x
i=0 i=1 i=2 i=3 i=4
x=0 x= 14 x= 12 x= 34 x=1
The unknown meshes are A(i = 1, j = 1), B(i = 2, j = 1) and C(i = 3, j = 1). Hence
the system of equations is
Using initial and boundary values the above system of equations becomes
This is a system of three linear equations with three unknowns. The solution of this
system is
u1,1 = u(0.25, 0.125) = 0.60714, u2,1 = u(0.50, 0.125) = 1.07143,
u3,1 = u(0.75, 0.125) = 1.10714.
Case II.
1 1 1
Let h = , k = . Therefore, r = 1. To find the value of u at t = , we have to solve
4 16 8
two systems of tri-diagonal equations in two steps.
The Crank-Nicolson scheme is
For this case, the initial and boundary conditions are shown in Figure 1.4.
9
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Partial Differential Equation: Parabolic
t
6u0,2 u1,2 u2,2 u3,2 u4,2
j=2, t= 18 u e e e u
D E F
u0,1 u1,1 u2,1 u3,1 u4,1
1
j=1, t= 16 u e e e u
A B C
u0,0 u1,0 u2,0 u3,0 u
j=0, t=0 u u u u u-4,0x
i=0 i=1 i=2 i=3 i=4
x=0 x= 14 x= 12 x= 34 x=1
That is, the initial values are, u0,0 = 0, u1,0 = 0.75, u2,0 = 1.5, u3,0 = 2.25, u4,0 = 3
and the boundary values are u0,1 = 0, u4,1 = 0; u0,2 = 0, u4,2 = 0.
Here, r = 1, so the middle term of right hand side of Crank-Nicolson equation
vanishes. Thus the Crank-Nicolson equations for first step, i.e. for the mesh points
A(i = 1, j = 1), B(i = 2, j = 1) and C(i = 3, j = 1) are respectively
−u0,1 + 4u1,1 − u2,1 = u0,0 + u2,0
−u1,1 + 4u2,1 − u3,1 = u1,0 + u3,0
−u2,1 + 4u3,1 − u4,1 = u2,0 + u4,0 .
That is,
4u1,1 − u2,1 = 0 + 1.5 = 1.5
−u1,1 + 4u2,1 − u3,1 = 0.75 + 2.25 = 3.0
−u2,1 + 4u3,1 = 1.5 + 3 = 4.5.
Using boundary conditions and values of right hand side obtained in first step, the
above system becomes
11
......................................................................................
Practice Questions
1. Solve the heat equation
∂u ∂2u
=α 2
∂t ∂x
subject to the conditions u(x, 0) = 0, u(0, t) = 0 and u(1, t) = 2t, taking h =
1/2, k = 1/16.
∂2u ∂u
2. Given the differential equation 2
= and the boundary condition u(0, t) =
∂x ∂t
2 2
u(5, t) = 0 and u(x, 0) = x (30 − x ). Use the explicit method to obtain the
solution for xi = ih, yj = jk; i = 0, 1, . . . , 5 and j = 0, 1, 2, . . . , 6.
∂u ∂2u
3. Solve the differential equation = , 0 ≤ x ≤ 1/2, given that u = 0 when
∂t ∂x2
∂u ∂u
t = 0, 0 ≤ x ≤ 1/2 and with boundary conditions = 0 at x = 0 and = 1 at
∂x ∂x
x = 1/2 for t > 0, taking h = 0.1, k = 0.001.
4. Solve the following initial value problem ft = fxx , 0 ≤ x ≤ 1 subject to the initial
πx
condition f (x, 0) = cos and the boundary conditions f (0, t) = 1, f (1, t) = 0 for
2
t > 0, taking h = 1/3, k = 1/3.
15
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Partial Differential Equation: Hyperbolic
In this module, two other types of partial differential equations are considered. These
are hyperbolic and elliptic PDEs. Finite difference method is also used to solve these
problems. First we consider hyperbolic equation.
The simplest problem of this class is one dimensional wave equation. This problem
may occurs in many real life situations. For example, the transverse vibration of a
stretched string, propagation of light and sound, propagation of water wave, etc. It
arises in different fields such as acoustics, electromagnetics, fluid dynamics, etc.
The simplest form of the wave equation is given below:
Let u = u(r, t), r ∈ Rn be a scalar function which satisfies
∂2u
= c2 ∇2 u, (2.1)
∂t2
where ∇2 is the Laplacian in Rn and c is a constant speed of the wave propagation.
This equation can also be written as
1 ∂2
2 u = 0, where 2 = ∇2 − . (2.2)
c2 ∂t2
The operator 2 is called d’Alembertian.
In case of one dimension, the above equation is
∂2u 2
2∂ u
= c , t > 0, 0 < x < 1. (2.3)
∂t2 ∂x2
The initial conditions are u(x, 0) = f (x) and
∂u
= g(x), 0 < x < 1 (2.4)
∂t (x,0)
and the boundary conditions are
In finite difference method, the partial derivatives uxx and utt are approximated by
the following central-difference schema at the mesh points (xi , tj ) = (ih, jk) are
1
uxx = (ui−1,j − 2ui,j + ui+1,j ) + O(h2 )
h2
1
and utt = 2 (ui,j−1 − 2ui,j + ui,j+1 ) + O(k2 ),
k
2
......................................................................................
where i, j = 0, 1, 2, . . ..
Using this approximation, the equation (2.3) reduces to
1 c2
2
(ui,j−1 − 2ui,j + ui,j+1 ) = 2 (ui−1,j − 2ui,j + ui+1,j ).
k h
That is,
ui,j+1 = r 2 ui−1,j + 2(1 − r 2 )ui,j + r 2 ui+1,j − ui,j−1 , (2.6)
where r = ck/h.
Note that the value of ui,j+1 depends on the values of u at two time-levels (j − 1), j
and the value of ui,j+1 can be determined if the four values ui−1,j , ui,j , ui+1,j , ui,j−1 are
known.
The known (filled circle) and unknown (circle) values of u are shown in Figure 2.1.
t
6
j+1 e
⊕ unknown values
j u u u u known values
j−1 u
- x
i−1 i i+1
Since, u(x, 0) = f (x), ui,0 = f (xi ) = fi . Using this notation, the above equation
reduces to
When j = 0, then
This formula gives the values of u for j = 1. For other values of j (j = 2, 3, . . .) the
values of u are calculated from the formula (2.10).
The initial and boundary values are shown in the following table.
4
......................................................................................
j = 5, t = 0.5 0 0
j = 4, t = 0.4 0 0
j = 3, t = 0.3 0 0
j = 2, t = 0.2 0 0
j = 1, t = 0.1 0 0
j = 0, t = 0.0 0 0.16 0.64 1.44 2.56 0
x=0 x = 0.2 x = 0.4 x = 0.6 x = 0.8 x = 1.0
i=0 i=1 i=2 i=3 i=4 i=5
Implicit Method-I
The right hand side of the equation (2.3) is divided into two parts. Now, by central-
difference approximation at the mesh point (ih, jk) the given equation reduces to
2 " #
c2 ∂2u
2
∂ u ∂ u
= + .
∂t2 i,j 2 ∂x2 i,j+1 ∂x2 i,j−1
That is,
1
[ui,j+1 − 2ui,j + ui,j−1 ] (2.11)
k2
c2
= 2 [(ui+1,j+1 − 2ui,j+1 + ui−1,j+1 ) + (ui+1,j−1 − 2ui,j−1 + ui−1,j−1 )].
2h
Implicit Method-II
Again, we divide the right hand side of the given equation into three parts as
" #
∂2u c2 ∂2u
2 2
∂ u ∂ u
= +2 + .
∂t2 i,j 4 ∂x2 i,j+1 ∂x2 i,j ∂x2 i,j−1
By central-difference approximation the given equation reduces to
1
[ui,j+1 − 2ui,j + ui,j−1 ]
k2
c2
= 2 [(ui+1,j+1 − 2ui,j+1 + ui−1,j+1 ) (2.12)
4h
+2(ui+1,j − 2ui,j + ui−1,j ) + (ui+1,j−1 − 2ui,j−1 + ui−1,j−1 )].
2s −1 0 0 0 ··· 0 0 u1,j+1 d1,j+1
−1 2s −1 0 0 · · · 0 0 u2,j+1 d2,j+1
0 −1 2s −1 0 · · · 0 0 u d
3,j+1 3,j+1
=
0 0 −1 2s −1 · · · 0 0 u4,j+1 d4,j+1
··· ··· ··· ··· ··· ··· ··· ··· ··· ···
0 0 0 0 0 · · · −1 2s uN −1,j+1 dN −1,j+1
d1,j = u0,j+1 + 2[u0,j − 2(1 − 2/r 2 )u1,j + u2,j ] + [u0,j−1 − 2(1 + 2/r 2 )u1,j−1 + u2,j−1 ]
di,j = 2[ui−1,j − 2(1 − 2/r 2 )ui,j + ui+1,j ]
+[ui−1,j−1 − 2(1 + 2/r 2 )ui,j−1 + ui+1,j−1 ]
i = 2, 3, . . . , N − 2
dN −1,j = uN,j+1 + 2[uN −2,j − 2(1 − 2/r 2 )uN −1,j + uN,j ]
+[uN −2,j−1 − 2(1 + 2/r 2 )uN −1,j−1 + uN,j−1 ]
For a particular value of j = k, k = 1, 2, . . ., one can find all values of ui,k , for
i = 1, 2, . . . , N − 1.
Both the formulae are valid for all values of r = ck/h > 0.
7
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Partial Differential Equation: Hyperbolic
Practice Questions
1. The differential equation utt = uxx , 0 ≤ x ≤ 1 satisfies the boundary conditions
πx
u = 0 at x = 0 and x = 1 for t > 0, and the initial conditions u(x, 0) = sin ,
4
∂u
= 0. Compute the values of u for x = 0, 0.1, 0.2, . . . , 0.5 and t =
∂t (x,0)
0, 0.1, 0.2, . . . , 0.5.
10
......................................................................................
Elliptic PDE is one of the widely used PDEs. In this module, the finite difference
method is described to solve the elliptic PDEs.
The elliptic PDEs occur in many practical situations. The most simple elliptic PDEs
are Laplace and Poisson equations. The Laplace equation is ∇n u = 0 and Poisson
equation is ∇n u = g(r).
One physical example of such equations is stated below.
Let the function ρ represent the electric charge density in some open bounded set
Ω ⊂ Rd . If the permittivity ε is constant in Ω the distribution of the electric potential
ϕ in Ω is governed by the Poisson equation
−ε∆ϕ = ρ.
This equation does not have a unique solution, because if φ is a solution of this
equation, then the function φ + c, is also a solution, where c is any constant. To get a
solution, every elliptic equation should have a suitable boundary conditions.
Let us consider the two-dimensional Laplace equation
∂2u ∂2u
+ 2 = 0 within the region R (3.1)
∂x2 ∂y
and u = f (x, y) on the boundary C.
In this problem, both are space variables. Now, we approximate this PDE by the
central difference approximation. Then the finite difference approximation of the above
equation is
ui−1,j − 2ui,j + ui+1,j ui,j−1 − 2ui,j + ui,j+1
+ = 0. (3.2)
h2 k2
It is assumed that the length of the subintervals along x and y directions are equal,
i.e. h = k. Then the above equation becomes,
1
ui,j = [ui+1,j + ui−1,j + ui,j+1 + ui,j−1 ]. (3.3)
4
From this expression, it is seen that the value of ui,j is the average of the values of u
at the four meshes – north (i, j + 1), east (i + 1, j), south (i, j − 1) and west (i − 1, j).
1
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Partial Differential Equation: Elliptic
y
6(i, j+1)
u
u e u
(i-1,j) (i,j) (i+1,j)
u - x
(i,j-1)
The known values (filled circles) and unknown (circle) are shown in Figure 3.1. This
formula is known as standard five-point formula.
It can be proved that the Laplace equation remains invariant when the coordinates
axes are rotated at an angle 450 .
Under this rotation, the equation (3.3) becomes
1
ui,j = [ui−1,j−1 + ui+1,j−1 + ui+1,j+1 + ui−1,j+1 ]. (3.4)
4
This is another formula to calculate ui,j and it is known as diagonal five-point
formula. The known and unknown meshes for this formula are shown in Figure 3.2.
y
6
u
(i-1,j+1)
u (i+1,j+1)
e
(i,j)
u u- x
(i-1,j-1) (i+1,j-1)
When the right hand side of the Laplace equation is nonzero, then this equation
is known as Poisson’s equation. The Poisson’s equation in two-dimension is in the
following form
Here, we also assumed that the mesh points in both x and y directions are uniform.
Using this assumption the central difference approximation of the equation (3.5) is
reduced to
1
ui,j = [ui−1,j + ui+1,j + ui,j−1 + ui,j+1 − h2 gi,j ] where gi,j = g(xi , yj ). (3.6)
4
Let u = 0 along the boundary C and i, j = 0, 1, 2, 3, 4. Then u0,j = 0, u4,j = 0 for
j = 0, 1, 2, 3, 4 and ui,0 = 0, ui,4 = 0 for i = 0, 1, 2, 3, 4. The boundary values (filled
circles) are shown in Figure 3.3.
y
6 u=0
j=4 u u u u u
j=3 u e e e u
u1,3 u2,3 u3,3
u=0, j=2 u e e e u u=0
u1,2 u2,2 u3,2
j=1 u e e e u
u1,1 u2,1 u3,1
j=0 u u u u u- x
i=0 i=1 i=2 i=3 i=4
u=0
For a particular case, i.e. for i, j = 1, 2, 3 the equation (3.6) becomes a system of nine
equations with nine unknowns. These equations are written in matrix notation as
4 −1 0 −1 0 0 0 0 0 u1,1 −h2 g1,1
−1 4 −1 0 −1 0 0 0 0 u1,2 −h2 g1,2
0 −1 4 0 0 −1 0 0 0
u
−h 2g
1,3 1,3
−1 0 0 4 −1 0 −1 0 0 u2,1 −h2 g2,1
0 −1 0 −1 4 −1 0 −1 0 u2,2 = −h2 g2,2 (3.7)
0 0 −1 0 −1 4 0 0 −1 u −h2 g
2,3 2,3
0 0 0 −1 0 0 4 −1 0 u3,1 −h2 g3,1
0 0 0 0 −1 0 −1 4 −1 u −h2 g
3,2 3,2
0 0 0 0 0 −1 0 −1 4 u3,3 −h2 g3,3
3
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Partial Differential Equation: Elliptic
This indicates that the equation (3.6) is a system of N (where N is the number of
subintervals along x and y directions) equations. Note that the coefficient matrix is
symmetric, positive definite and sparse (many elements are 0). Since, the coefficient
matrix is sparse, so it is suggested to use iterative method rather than direct method
to solve the above system of equations. Commonly used iterative methods are Jacobi’s
method, Gauss-Seidel’s method, successive overrelaxation method, alternate direction
implicit method, etc.
Let us consider the Laplace’s equation uxx + uyy = 0. Let the region R be square
and it is divided into N × N small squares each of side h. The boundary values are
u0,j , uN,j , ui,0 , ui,N where i, j = 0, 1, 2, . . . , N , shown in Figure 3.4.
y
u1,4 u2,4 u3,4 u4,4
u0,4 6 u u u u u
u0,3 u e e e u u4,3
u1,3 u2,3 u3,3
u0,2 u e e e u u4,2
u1,2 u2,2 u3,2
u0,1 u e e e u u4,1
u1,1 u2,1 u3,1
u u u u u- x
u0,0 u1,0 u2,0 u3,0 u4,0
Figure 3.4: Known and unknown meshes for Laplace equation. Red meshes are cal-
culated by diagonal five-point formula and blue meshes are determined by standard
five-point formula
At first the diagonal five-point formula is used to compute the values of u according
to the order u2,2 , u1,3 , u3,3 , u1,1 and u3,1 (red meshes in the figure). That is,
1
u2,2 = (u0,0 + u4,4 + u0,4 + u4,0 )
4
1
u1,3 = (u0,2 + u2,4 + u0,4 + u2,2 )
4
4
......................................................................................
1
u3,3 = (u2,2 + u4,4 + u2,4 + u4,2 )
4
1
u1,1 = (u0,0 + u2,2 + u0,2 + u2,0 )
4
1
u3,1 = (u2,0 + u4,2 + u2,2 + u4,0 ).
4
In the second step, the remaining values, viz., u2,3 , u1,2 , u3,2 and u2,1 are evaluated
using standard five-point (blue meshes in the figure). Thus,
1
u2,3 = (u1,3 + u3,3 + u2,2 + u2,4 )
4
1
u1,2 = (u0,2 + u2,2 + u1,1 + u1,3 )
4
1
u3,2 = (u2,2 + u4,2 + u3,1 + u3,3 )
4
1
u2,1 = (u1,1 + u3,1 + u2,0 + u2,2 ).
4
Note that these are the first approximate values of u at different meshes. These values
can be updated by using any iterative methods mentioned earlier.
uxx + uyy = 0,
u(x, 0) = 0, u(0, y) = 0,
u(x, 1) = 5x, u(1, y) = 5y.
Find the first approximate values at the interior meshes by dividing the square region
into 4 × 4 squares.
Solution. For this problem, the region R is 0 ≤ x, y ≤ 1. Let h = k = 0.25 and
xi = ih, yj = jk, i, j = 0, 1, 2, 3, 4. The meshes are shown in Figure 3.5.
The values of u are calculated in two steps. In first step, the diagonal five-point
formula is used to find the values of u2,2 , u1,3 , u3,3 , u1,1 , u3,1 and in second step the
standard five-point formula is used to find the values of u2,3 , u1,2 , u3,2 , u2,1 .
The diagonal five-point formula is
1
ui,j = [ui−1,j−1 + ui+1,j−1 + ui+1,j+1 + ui−1,j+1 ]
4
5
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Partial Differential Equation: Elliptic
y
u1,4 u2,4 u3,4 u4,4
6 1.25
u 2.50
u 2.75 5.0
y=1.00, u0,4 =0 u u u u4,4 =5.0
y=0.00, u0,0 =0 u u u u u- x
0 0 0 0
u1,0 u2,0 u3,0 u4,0
x=0 x= 41 x= 12 x= 34 x=1
Figure 3.5: Meshes for Dirichlet’s problem
1 1
u2,3 = (u1,3 + u3,3 + u2,2 + u2,4 ) = (0.9375 + 2.8125 + 1.25 + 2.5) = 1.875
4 4
1 1
u1,2 = (u0,2 + u2,2 + u1,1 + u1,3 ) = (0 + 1.25 + 0.3125 + 0.9375) = 0.625
4 4
1 1
u3,2 = (u2,2 + u4,2 + u3,1 + u3,3 ) = (1.25 + 2.5 + 0.9375 + 2.8125) = 1.875
4 4
1 1
u2,1 = (u1,1 + u3,1 + u2,0 + u2,2 ) = (0.3125 + 0.9375 + 0 + 1.25) = 0.625.
4 4
6
......................................................................................
If the first approximate values of u are known, then these values can be updated by
applying any well known iterative method. Several iterative methods are available with
different rates of convergence, some of them are discussed below.
The standard five-point finite-difference formula for the Poisson’s equation (3.5) is
1
ui,j = (ui−1,j + ui+1,j + ui,j−1 + ui,j+1 − h2 gi,j ). (3.8)
4
(r)
Let ui,j be the rth iterative value of ui,j , r = 1, 2, . . ..
Jacobi’s method
The Jacobi’s iterative scheme to solve the system of equations (3.8) for the interior
meshes is
Gauss-Seidel’s method
In it well known (discussed in Chapter 5) that the latest updated values are used in
Gauss-Seidel’s method. The values of u along each row are computed systematically
from left to right. The iterative formula is
In this method, the iteration scheme is accelerated by introducing a scalar, called re-
(r+1) (r)
laxation factor. This acceleration is made by making corrections on [ui,j − ui,j ].
(r+1)
Suppose ui,j is the value obtained from any iteration method, such as Jacobi’s or
7
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Partial Differential Equation: Elliptic
Gauss-Seidel’s method. Then the updated value of ui,j at the (r + 1)th iteration is given
by
(r+1) (r+1) (r)
ui,j = wui,j + (1 − w)ui,j , (3.11)
Example 3.2 Solve the Laplace’s equation uxx + uyy = 0 defined within the square
region 0 ≤ x ≤ 1 and 0 ≤ y ≤ 1 shown in Figure 3.6, by (a) Jacobi’s method, (b)
Gauss-Seidel’s method, and (c) Gauss-Seidel’s successive over-relaxation method.
u
12.4
e
u
12.4
e
u e
u
0 u e
u1,2
e
u2,2
u0
e
0 u e e e0
u
u1,1 u2,1
u u u u
0 0
Solution.
(a) Jacobi’s method
Let the initial values be u2,1 = u1,2 = u2,2 = u1,1 = 0 and h = k = 1/3.
The Jacobi’s iteration scheme is
8
......................................................................................
Therefore, u1,1 = 1.5500, u2,1 = 1.5500, u1,2 = 4.6500, u2,2 = 4.6500, correct up to
four decimal places.
(b) Gauss-Seidel’s method
Let u2,1 = u1,2 = u2,2 = u1,1 = 0 be the initial values. Also, h = k = 1/3.
9
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Partial Differential Equation: Elliptic
Hence, u1,1 = 1.55000, u2,1 = 1.55000, u1,2 = 4.65000, u2,2 = 4.65000, correct up to
five decimal places.
10
......................................................................................
Example 3.3 Solve the Poisson’s equation uxx + uyy = 5x2 y for the square region
0 ≤ x ≤ 1, 0 ≤ y ≤ 1 with h = 1/3 and the values of u on the boundary are every where
zero. Use (a) Gauss-Seidel’s method, and (b) Gauss-Seidel’s SOR method.
Solution. In this problem, g(x, y) = 5x2 y, h = k = 1/3 and the boundary conditions
are u0,0 = u1,0 = u2,0 = u3,0 = 0, u0,1 = u0,2 = u0,3 = 0,
u1,3 = u2,3 = u3,3 = 0, u3,1 = u3,2 = 0.
11
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Partial Differential Equation: Elliptic
The solution obtained by SOR method is u1,1 = −0.02315, u2,1 = −0.04115, u1,2 =
−0.03086, u2,2 = −0.05916, correct up to five decimal places.
Note that the Gauss-Seidel’s iteration method needs 7 iterations whereas SOR method
takes only 6 iteration for w = 1.1.
13
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Partial Differential Equation: Elliptic
Practice Questions
1. Solve the Poisson’s equation uxx + uyy = −2x2 + y 2 over the region 0 ≤ x ≤ 2, 0 ≤
y ≤ 2 taking the boundary condition u = 0 on all the boundary sides with h = 0.5.
Use Gauss-Seidel’s method to improve the solution.
2. Solve the Laplace equation uxx + uyy = 0 taking h = 1, with boundary values as
shown below.
8u 10u 12u
0 u u16
0 u e e e u28
u1,3 u2,3 u3,3
0 u e e e u24
u1,2 u2,2 u3,2
0 u e e e
u2,1 u3,1
u22
u1,1
0 u u u u u20
10 15 18
3. Solve the elliptic differential equation uxx + uyy = 0 and for the region bounded
by 0 ≤ x ≤ 5, 0 ≤ y ≤ 5, the boundary conditions being
u = 0 at x = 0 and u = 2 + y at x = 5,
u = x2 at y = 0 and u = 2x at y = 5.
Take h = k = 1. Use
(a) Jacobi’s method, (b) Gauss-Seidel’s method, and (c) Gauss-Seidel’s S.O.R.
method.
16