Unit-V Numerical Methods For PDE-2
Unit-V Numerical Methods For PDE-2
of Mathematics
Evaluate the approximate solutions of partial differential equations using numerical meth-
ods.
Introduction
Partial differential equations arise in the study of many branches of applied mathematics
e.g. in fluid dynamics, heat transfer, boundary layer flow, elasticity, quantum mechanics and
electro-magnetic theory. Only a few or these equations can be solved by analytical methods
which are also complicated and require use of advanced mathematical techniques. In most
of these, it is easier to obtain approximate solutions by numerical methods.
∂ 2u ∂ 2u ∂ 2u
∂u ∂u
A(x, y) 2 + B(x, y) + C(x, y) 2 + F x, y, u, , =0 (1)
∂x ∂x∂y ∂y ∂x ∂y
Y
R
(x, y + k)
b
(i, j + 1)
(x − h, y) (x, y) (x + h, y)
b b b b
(i, j)
∆y = k
(i − 1, j) (i + 1, j)
(i, j − 1)
b
(x, y − k)
0
∆x = h X
Figure 1
Then the finite difference approximations for the partial derivatives w.r.t x are
∂u u(x + h, y) − u(x, y)
= + O(h) Forward difference approximation
∂x h
u(x, y) − u(x − h, y)
= + O(h) Backward difference approximation
h
u(x + h, y) − u(x − h, y)
= + O(h2 ) Central difference approximation
2h
∂ 2u u(x − h, y) − 2u(x, y) + u(x + h, y)
and = + O(h2 )
∂x2 h2
Writing u(x, y) = u(ih, jk) as simply ui,j , the above approximations become
ui+1,j − ui,j
ux = + O(h) Forward difference approximation (2)
h
ui,j − ui−1,j
= + O(h) Backward difference approximation (3)
h
ui+1,j − ui−1,j
= + O(h2 ) Central difference approximation (4)
2h
ui−1,j − 2ui,j + ui+1,j
and uxx = + O(h2 ) (5)
h2
Similarly we have the approximations for the derivative w.r.t y:
ui,j+1 − ui,j
uy = + O(k) (6)
k
ui,j − ui,j−1
= + O(k) (7)
k
ui,j+1 − ui,j−1
= + O(k 2 ) (8)
2k
ui,j−1 − 2ui,j + ui,j+1
and uyy = + O(k 2 ) (9)
k2
Replacing the derivatives in any partial differential equation by their corresponding differ-
ence approximations given in formulae (2) to (9), we obtain the finite-difference analogues
of the given equation.
1 1
2
[ui−1,j − 2ui,j + ui+1,j ] + 2 [ui,j−1 − 2ui,j + ui,j+1 ] = 0
h h
1
or ui,j = [ui−1,j + ui+1,j + ui,j+1 + ui,j−1 ] (11)
4
This shows that the value of ui,j at any interior mesh point is the average of its values at
b1,4
u2,4 u3,4 u4,4 b5,4
b1,3
u2,3 u3,3 u4,3 b5,3
Figure 2
four neighbouring points to the left, right, above and below. The formula (11) is called the
standard 5−point formula which is exhibited in figure 3. Sometimes a formula similar to
ui+j+1
b
ui−1,j ui,j ui+1,j
ui,j−1
Figure 3
1
ui,j = [ui−1,j+1 + ui+1,j−1 + ui+1,j+1 + ui−1,j−1 ] (12)
4
This shows that the value of ui,j is the average of its values at the four neighbouring diagonal
mesh points given in formula (12) is called the diagonal 5−point formula which is given
in figure 4. Although (12) is less accurate than (11), yet it serves as a reasonably good
approximation for obtaining the starting values at the mesh points.
ui−1,j+1
ui+1,j+1
b
ui,j ui+1,j
ui−1,j−1 ui+1,j−1
Figure 4
Example 1. Given the values of u(x, y) on the boundary of the sware in fig 5, evaluate the
function u(x, y) satisfying uxx + uyy = 0 at the pivotal points of this figure.
Figure 5
1
u1 = (1000 + 0 + 1000 + 2000) = 1000 (Diag.F ormula) (13)
4
1
u2 = (1000 + 500 + 1000 + 0) = 625 (Std.F ormula) (14)
4
1
u3 = (2000 + 0 + 1000 + 500) = 875 (Std.F ormula) (15)
4
1
u4 = (875 + 0 + 625 + 0) = 375 (Std.F ormula) (16)
4
III Semester Statistics, Laplace Transforms and
4 Numerical Methods for PDE [MA231TB]
Dept. of Mathematics
(1) 1
u1 = (2000 + 625 + 1000 + 875) = 1125
4
(1) 1
u2 = (1125 + 500 + 1000 + 375) = 750
4
(1) 1
u4 = (2000 + 375 + 1125 + 500) = 1000
4
(1) 1
u5 = (1000 + 0 + 750 + 0) ≈ 438
4
Second iteration: (put n = 1)
(2) 1
u1 = (2000 + 750 + 1000 + 1000) ≈ 1188
4
(2) 1
u2 = (1188 + 500 + 1000 + 438) ≈ 782
4
(2) 1
u3 = (2000 + 438 + 1188 + 500) ≈ 1032
4
(2) 1
u4 = (1032 + 0 + 782 + 0) ≈ 454
4
Third iteration: (put n = 2)
(3) 1
u1 = (2000 + 782 + 1000 + 1032) ≈ 1204
4
(3) 1
u2 = (1204 + 500 + 1000 + 454) ≈ 789
4
(3) 1
u3 = (2000 + 454 + 1204 + 500) ≈ 1040
4
(3) 1
u4 = (1040 + 0 + 789 + 0) ≈ 458
4
(4) (4) (4) (4)
Similarly, u1 ≈ 1207, u2 ≈ 791, u3 ≈ 1041, u4 ≈ 458
(5) (5) (5) (5)
u1 ≈ 1208, u2 ≈ 791.5, u3 ≈ 1041.5, u4 ≈ 458.25
Thus there is no significant difference between the fourth and fift iteration values.
(4) (4) (4) (4)
Hence u1 ≈ 1208, u2 ≈ 792, u3 ≈ 1042, u4 ≈ 458
Example 2. Solve the Laplace equation uxx + uyy = 0 for the following square mesh with
III Semester Statistics, Laplace Transforms and
5 Numerical Methods for PDE [MA231TB]
Dept. of Mathematics
Figure 6
1
u5 = (0 + 17 + 21 + 12.1) = 12.5 (Std.F ormula)
4
1
u1 = (0 + 12.5 + 0 + 17) = 7.4 (Dig.F ormula)
4
1
u3 = (12.5 + 18.6 + 17 + 21) = 17.28 (Dig.F ormula)
4
1
u7 = (12.5 + 0 + 0 + 12.1) = 6.15 (Dig.F ormula)
4
1
u9 = (12.5 + 9 + 21 + 12.1) = 13.65 (Dig.F ormula)
4
1
u2 = (17 + 12.5 + 7.4 + 17.3) = 13.55 (Std.F ormula)
4
1
u4 = (7.4 + 6.2 + 0 + 12.5) = 6.52 (Std.F ormula)
4
1
u6 = (17.3 + 13.7 + 12.5 + 21) = 16.12 (Std.F ormula)
4
1
u8 = (12.5 + 12.1 + 6.2 + 13.7) = 11.12 (Std.F ormula)
4
Example 3. Solve the elliptic equation uxx + uyy = 0 for the following square mesh with
boundary values as shown in figure 7.
u1 u2 u3
1000 1000
A u4 u5 u6 B
2000 2000
u7 u8 u9
1000 1000
D
0 500 0
1000 500
Figure 7
1
u5 = (2000 + 2000 + 1000 + 1000) = 1500 (Std.F ormula) (21)
4
1
u1 = (0 + 1500 + 1000 + 2000) = 1125 (Diag.F ormula) (22)
4
1
u2 = (1125 + 1125 + 1000 + 1500) ≈ 1188 (Std.F ormula) (23)
4
1
u4 = (2000 + 1500 + 1125 + 1125) ≈ 1438 (Std.F ormula) (24)
4
We carry out the iteration process using the formulae:
(1) 1
u1 = (1000 + 1188 + 500 + 1438) ≈ 1032
4
(1) 1
u2 = (1032 + 1125 + 1000 + 1500) = 1164
4
(1) 1
u4 = (2000 + 1500 + 1032 + 1125) = 1414
4
(1) 1
u5 = (1414 + 1438 + 1164 + 1188) = 1301
4
Second iteration: (put n = 1)
(2) 1
u1 = (1000 + 1164 + 500 + 1414) = 1020
4
(2) 1
u2 = (1020 + 1032 + 1000 + 1301) = 1088
4
(2) 1
u4 = (2000 + 1301 + 1020 + 1032) = 1338
4
(2) 1
u5 = (1338 + 1414 + 1088 + 1164) = 1251
4
Third iteration: (put n = 2)
(3) 1
u1 = (1000 + 1088 + 500 + 1338) = 982
4
(3) 1
u2 = (982 + 1020 + 1000 + 1251) = 1063
4
(3) 1
u4 = (2000 + 1251 + 982 + 1020) = 1313
4
(3) 1
u5 = (1313 + 1338 + 1063 + 1088) = 1201
4
Fourth iteration: (put n = 3)
(4) 1
u1 = (1000 + 1063 + 500 + 1313) = 969
4
(4) 1
u2 = (969 + 982 + 1000 + 1201) = 1038
4
(4) 1
u4 = (2000 + 1201 + 969 + 982) = 1288
4
(4) 1
u5 = (1288 + 1313 + 1038 + 1063) = 1176
4
(5) 1
u1 = (1000 + 1038 + 500 + 1288) = 957
4
(5) 1
u2 = (957 + 969 + 1000 + 1176) ≈ 1026
4
(5) 1
u4 = (2000 + 1176 + 957 + 969) ≈ 1276
4
(5) 1
u5 = (1276 + 1288 + 1026 + 1038) = 1157
4
Similarly,
(6) (6) (6) (6)
u1 = 951, u2 = 1016, u4 = 1266, u5 = 1146
(7) (7) (7) (7)
u1 = 946, u2 = 1011, u4 = 1260, u5 = 1138
(8) (8) (8) (8)
u1 = 943, u2 = 1007, u4 = 1257, u5 = 1134
(9) (9) (9) (9)
u1 = 941, u2 = 1005, u4 = 1255, u5 = 1131
(10) (10) (10) (10)
u1 = 940, u2 = 1003, u4 = 1253, u5 = 1129
(11) (11) (11) (11)
u1 = 939, u2 = 1002, u4 = 1252, u5 = 1128
(12) (12) (12) (12)
u1 = 939, u2 = 1001, u4 = 1251, u5 = 1126
Thus there is negligible difference between the values obtained in the 11th and 12th itera-
tions.
Hence u1 = 939, u2 = 1001, u4 = 1251 and u5 = 1126.
∂u ui,j+1 − ui,j
=
∂t k
∂ 2u ui−1,j − 2ui,j + ui+1,j
and =
∂x2 h2
kc2
ui,j+1 − ui,j = [ui−1,j − 2ui,j + ui+1,j ]
h2
or ui,j+1 = αui−1,j + (1 − 2α)ui,j + αui+1,j (30)
t
(i, j + 1)b (j + 1) th level
b h b b
j th level
(i − 1, j) (i, j) (i + 1, j)
x
Figure 8
1
ui,j+1 = (ui−1,j + ui+1,j ) (31)
2
which shows that the values of u at xi at time tj+1 is the mean of the u values at xi−1 and
xi+1 at time tj . This relation, known as Bendre-Schmidt recurrence relation, gives the
values of u at the internal mesh points with the help of boundary conditions.
∂u ∂ 2u
Example 4. Find the values of u(x, t) satisfying the parabolic equation = 4 2 and
∂t ∂x
the boundary conditions u(0, t) = 0 = u(8, t) and u(x, 0) = 4x − 21 x2 at the points x = i :
i = 0, 1, 2, . . . , 8 and t = 18 j : j = 0, 1, 2, . . . , 5.
These are the entries of the first row. Putting j = 0 in the formula, we have
ui,1 = 21 (ui−1,1 + ui+1,0 )
Taking i = 1, 2, . . . , 8 successively, we get
1 1
u1,1 = (u0,0 + u2,0 ) = (0 + 6) = 3
2 2
1 1
u2,1 = (u1,0 + u3,0 ) = (3.5 + 7.5) = 5.5
2 2
1 1
u3,1 = (u2,0 + u4,0 ) = (6 + 8) = 7
2 2
u4,1 = 7.5, u5,1 = 7, u6,1 = 5.5, u7,1 = 3.
These are the entries in the second row. Putting j = 1 in the formula, the entries of the third
row are given by
1
u1,2 = (ui−1,1 + ui+1,1 )
2
Similarly putting j = 2, 3, 4 successively in formula, the entries of the fourth, fifth and sixth
rows are obtained. Hence the values of ui,j are as given in the following table:
i
H
HH
H 0 1 2 3 4 5 6 7 8
j HH
H
0 0 3.5 6 7.5 8 7.5 6 3.5 0
1 0 3 5.5 7 7.5 7 5.5 3 0
2 0 2.75 5 6.5 7 6.5 5 2.75 0
3 0 2.5 4.625 6 6.5 6 4.625 2.5 0
4 0 2.3125 4.25 5.5625 6 5.5625 4.25 2.3125 0
5 0 2.125 3.9375 5.125 5.5625 5.125 3.9375 2.125 0
∂u ∂ 2u
Example 5. Solve the equation = subject to the conditions u(x, 0) = sin πx,
∂t ∂x2
0 ≤ x ≤ 1; u(0, t) = u(1, t) = 0, using Schmidt method. Carryout computations for two
levels, taking h = 1/3, k = 1/36.
x
HH
H
HH 0 1/3 2/3 1
t
√ √
HH
3 3
0 0 0
2 2
1/36 0 0.6495 0.6495 0
2/36 0 0.4871 0.4871 0
∂u
subject to the initial conditions : u = f (x),= g(x), 0 ≤ x ≤ 1at t = 0 (33)
∂t
and the boundary conditions : u(0, t) = φ(t), u(1, t) = ψ(t) (34)
Consider a rectangular mesh in the x − t plane spacing h along x direction and k along time
t direction. Denoting a mesh point (x, t) = (ih, jk) as simply i, j, we have
c2 k 2
ui, j−1 − 2ui, j + ui, j+1 = (ui−1, j − 2ui, j + ui+1, j )
h2
or ui, j+1 = 2(1 − α2 c2 )ui,j + α2 c2 (ui−1, j + ui+1, j ) − ui, j−1 (37)
where α = k/h
Now replacing the derivative in (33) by its central difference approximation, we get
ui,j+1 − ui,j−1 ∂u
= = g(x)
2k ∂t
ui,j+1 = ui,j−1 + 2kg(x) at t = 0
ui,1 = ui,−1 + 2kg(x) for j = 0 (38)
Also initial condition u = f (x) at t = 0 becomes ui,−1 = f (x) (39)
Combining (38) and (39), we have ui,1 = f (x) + 2kg(x) (40)
Also the boundary condition (34) gives u0,j = φ(t) and u1,j = ψ(t).
Hence the explicit form in (37) gives the values of ui,j+1 at the (j + 1)th level when the
nodal values at (j − 1)th and jth levels are known from equations (39) and (40) as shown in
figure 9.
Note 1. The coefficient of ui,j in the formula (37) will vanish if αc = 1 of k = h/c. Then
the formula (37) reduces to the simple form
Note 2. For α = 1/c, the solution of (37) is stable and coincides with the solution of (32)
For α < 1/c, the solution is stable but inaccurate.
For α > 1/c, the solution is unstable.
Note 3. The formula (37) converges for α ≤ 1 i.e. k ≤ h.
t ψ(t)
b b b b b
φ(t)
b b b b b 1st level
f (x) + kg(x)
b b b b
b 2nd level
k
h
f (x) x
Figure 9
Example 6. Evaluate the pivotal values of the equation utt = 16uxx , taking ∆x = 1 upto
t = 1.25. The boundary conditions are u(0, t) = u(5, t) = 0, ut (x, 0) = 0 and u(x, 0) =
x2 (5 − x).
Solution Here c2 = 16
III Semester Statistics, Laplace Transforms14
and Numerical Methods for PDE [MA231TB]
Dept. of Mathematics
ui, j+1 = 2(1 − 16α2 )ui,j + 16α2 (ui−1, j + ui+1, j ) − ui, j−1 (42)
where α = k/h.
Taking h = 1 and choosing k so that the coefficient of ui,j vanishes, we have 16α2 = 1, i.e.
k = h/4 = 1/4.
∴ the formula in (42) reduces to
which gives a convergent solution (since k/h < 1). Its solution coincides with the solution
of the given differential equation.
Now since u(0, t) = u(5, t) = 0, u0,j = 0 and u5,j = 0 for all values of j
i.e. the entries in the first and last columns are zero.
Since ux,0 = x2 (5 − x)
∴ ui,0 = i2 (5 − i) = 4, 12, 18, 16 for i = 1, 2, 3, 4 at t = 0.
These are the entries for the first row.
Finally since ut(x,0) = 0 becomes
ui,j+1 − ui,j−1
∴ = 0, when j = 0, giving ui,1 = ui,−1 (44)
2k
Thus the entries of the second row are the same as those of the first row.
Putting j = 0 in (43)
ui,1 = ui−1,0 + ui+1,0 − ui,−1 = ui−1,0 + ui+1,0 − ui,1 ,
1
or ui,1 = (ui−1,0 + ui+1,0 )
2
Taking i = 1, 2, 3, 4 successively, we obtain
1 1
u1,1 = (u0,0 + u2,0 ) = (0 + 12) = 6
2 2
1 1
u2,1 = (u1,0 + u3,0 ) = (4 + 18) = 11
2 2
1 1
u3,1 = (u2,0 + u4,0 ) = (12 + 16) = 14
2 2
1 1
u4,1 = (u3,0 + u5,0 ) = (18 + 0) = 9
2 2
These are the entries of the second row.
Putting j = 1 in (43), we get ui,2 = ui−1,1 + ui+1,1 − ui,0
i
PP
PP
P PP 0 1 2 3 4 5
j P PP
P
0 0 4 12 18 16 0
1 0 6 11 14 9 0
2 0 7 8 2 -2 0
3 0 2 -2 -8 -7 0
4 0 -9 -14 -11 -6 0
5 0 -16 -18 -12 -4 0
Example 7. The transverse displacement u of a point at a distance x from one end and at
∂ 2u ∂ 2u
any time t of a vibrating string satisfies the equation 2 = 4 2 , with boundary conditions
∂t ∂x
u = 0 at x = 0, t > 0 and u = 0 at x = 4, t > 0 and initial conditions u = x(4 − x)
∂u
and = 0, 0 ≤ x ≤ 4. Solve this equation numerically for one half period of vibration,
∂t
taking h = 1 and k = 1/2.
ui,j+1 − ui,j−1
= 0 when j = 0, giving ui,1 = ui,−1 (46)
2k
Putting j = 0 in (45)
1 1 1
u1,1 = (u0,0 + u1,0 ) = 2; u2,1 = (u1,0 + u3,0 ) = 3; u3,1 = (u2,0 + u4,0 ) = 2
2 2 2
HH i
HH
0 1 2 3 4
j H
HH
0 0 3 4 3 0
1 0 2 3 2 0
2 0 0 0 0 0
3 0 -2 -3 -2 0
4 0 -3 -4 -3 0