Ajiet: Lecture Notes VTU - 21MAT31, Module 4 - Numerical Solution of PDE

Download as pdf or txt
Download as pdf or txt
You are on page 1of 28

IET

Lecture Notes

VTU - 21MAT31, Module 4 - Numerical


Solution of PDE
AJ

Prepared By

Dr. Shantha Kumari. K.

AJIET, Mangaluru
Module 4

Numerical Solution of Partial Differential


Equations

The general second order linear PDE in two independent variables x, y is of the form

Auxx + Buxy + Cuyy + Dux + Euy + F u = 0


IET
where A, B, C, D, E, F are in general, functions of x and y. This equation is said to be

1. Parabolic if B 2 − 4AC = 0

2. Elliptic if B 2 − 4AC < 0


AJ

3. Hyperbolic if B 2 − 4AC > 0

Now let us examine the nature of three PDEs which are under our discussion.
PDE A B C B 2 − 4AC Nature of the PDE
One dimensional wave equation: c2 uxx − utt = 0 c2 0 −1 4c2 > 0 Hyperbolic
One dimensional heat equation: c2 uxx − ut = 0 c2 0 0 0 Parabolic
Two dimensional Laplace’s equation: uxx + uyy = 0 1 0 1 −4 < 0 Elliptic

Problem 1. Classify the following equations:


2 ∂2u 2
(i) ∂∂xu2 + 4 ∂x∂y + 4 ∂∂yu2 − ∂u
∂x
+ 2 ∂u
∂y
=0
2 2
(ii) x2 ∂∂xu2 + (1 − y 2 ) ∂∂yu2 = 0, − ∞ < x < ∞, − 1 < y < 1
2 2 2
∂ u
(iii) (1 + x2 ) ∂∂xu2 + (5 + 2x2 ) ∂x∂t + (4 + x2 ) ∂∂tu2 = 0.
(iv) y 2 uxx − 2yuxy + uyy − uy = 8y

Solution: (i) Comparing this equation with general form

Auxx + Buxy + Cuyy + Dux + Euy + F u = 0

1
Lecture Notes - 21MAT31, Module 4 - Numerical Solution of PDE Page 2

we find that
A = 1, B = 4, C = 4
∴ B 2 − 4AC = (4)2 − 4 × 1 × 4 = 0
So the equation is parabolic.
(ii) Here A = x2 , B = 0, C = 1 − y 2

B 2 − 4AC = 0 − 4x2 1 − y 2 = 4x2 y 2 − 1


 

For all x between −∞ and ∞, x2 is positive


For all y between −1 and 1, y 2 < 1

B 2 − 4AC < 0

Hence the equation is elliptic


(iii) Here A = 1 + x2 , B = 5 + 2x2 , C = 4 + x2
2
B 2 − 4AC = 5 + 2x2 − 4 1 + x2 (4 + x2 ) = 9 i.e. > 0


So the equation is hyperbolic


IET
(iv) Here A = y 2 , B = −2y, C = 1

∴ B 2 − 4AC = 4y 2 − 4y 2 = 0

So the equation is parabolic.


AJ

4.1 Finite difference approximation to the partial derivatives :

Let u = u(x, y) be a function of two independent variables. The finite difference approximation
for the first order partial derivatives: ux , uy and second order partial derivatives: uxx , yyy are as

Dr. Shantha Kumari.K. AJIET, Mangaluru


Lecture Notes - 21MAT31, Module 4 - Numerical Solution of PDE Page 3

follows.
∂u u(x + h, y) − u(x, y)
ux = =
∂x h
∂u u(x, y) − u(x − h, y)
ux = =
∂x h
∂u u(x + h, y) − u(x − h, y)
ux = =
∂x 2h
∂u u(x, y + k) − u(x, y)
uy = =
∂y k
∂u u(x, y) − u(x, y − k)
uy = =
∂y k
∂u u(x, y + k) − u(x, y − k)
uy = =
∂y 2k
∂ 2u 1
uxx = = [u(x + h, y) − 2u(x, y) + u(x − h, y)]
∂x2 h2
∂ 2u 1
uyy = = [u(x, y + k) − 2u(x, y) + u(x, y − k)]
∂y 2 k2
IET
4.2 Numerical solution of a PDE

Consider a rectangular region R in the x − y plane. Let us divide this region into a network of
reetangles of sides h and k. In other words, we draw lines x = ih, y = jk; i, j = 1, 2, 3, · · ·
being parallel to the Y - axis and X axis respectively resulting lito a network of rectangles. The
points of intersection of these lines are called mesh points or grid points or pivotal points.
AJ

Dr. Shantha Kumari.K. AJIET, Mangaluru


Lecture Notes - 21MAT31, Module 4 - Numerical Solution of PDE Page 4

We write u(x, y) = u(ih, jk) and the finite difference approximation for the partial derivatives
approximation for the partial derivatives given above are put in the following modified form.
1
ux = [ui+1,j − ui,j ]
h
1
ux = [ui,j − ui−1,j ]
h
1
ux = [ui+1,j − ui−1,j ]
2h
1
uy = [ui,j+1 − ui,j ]
k
1
uy = [ui,j − ui,j−1 ]
k
1
uy = [ui,j+1 − ui,j−1 ]
2k
1
uxx = [ui−1,j − 2ui,j + ui+1,j ]
h2
1
uyy = [ui,j−1 − 2ui,j + ui,j+1 ]
k2
IET
4.3 Numerical solution of the Laplace’s equation :

The Laplace’s equation in two dimensions is

∂ 2u ∂ 2u
+ =0
∂x2 ∂y 2
AJ

We consider a rectangular region R for which u(x, y) is known at the boundary. Let us suppose that
the region is such that it can be divided into a network of square mesh of side h. Then the value of
ui,j at any interior mesh point is given by

1
ui,j = [ui−1,j + ui+1,j + ui,j+1 + ui,j−1 ]
4

This is called the standard five point formula. This shows that the value of ui,j at any interior mesh
point is the average of its values at four neighbouring points to the left, right, above and below.

Dr. Shantha Kumari.K. AJIET, Mangaluru


Lecture Notes - 21MAT31, Module 4 - Numerical Solution of PDE Page 5

we repeatedly use the following formula by substituting the latest values available and this procedure
is called Liebmann’s iteration process.

(n+1) 1 h (n) (n) (n) (n)


i
ui,j = ui−1,j + ui+1,j + ui,j+1 + ui,j−1
4
for n = 0, 1, 2 · · · T
Note : Sometimes a formula similar to the above formula is used which is given by

1
IE
ui,j = [ui−1,j+1 + ui+1,j−1 + ui+1,j+1 + ui−1,j−1 ]
4
AJ

This is called the diagonal 5-point formula. This shows that the value of ui,j is the average of its val-
ues at the four neighbouring diagonal mesh points. diagonal 5-point formula serves as a reasonably
good approximation for obtaining the starting values at the mesh points.

Problem 2. Solve the Laplace equation uxx + uyy = 0 given that

Dr. Shantha Kumari.K. AJIET, Mangaluru


Lecture Notes - 21MAT31, Module 4 - Numerical Solution of PDE Page 6

Solution. We first find the initial values in the following order :


1
u5 = (0 + 17 + 21 + 12.1) = 12.5 (Std. formula)
4
1
IET
u1 = (0 + 12.5 + 0 + 17) = 7.4 (diagonal formula)
4
1
u3 = (12.5 + 18.6 + 17 + 21) = 17.28 (diagonal formula)
4
1
u7 = (12.5 + 0 + 0 + 12.1) = 6.15 (diagonal formula)
4
1
u9 = (12.5 + 9 + 21 + 12.1) = 13.65 (diagonal formula)
AJ

4
1
u2 = (17 + 12.5 + 7.4 + 17.3) = 13.55 (Std. formula)
4
1
u4 = (7.4 + 6.2 + 0 + 12.5) = 6.52 (Std. formula)
4
1
u6 = (17.3 + 13.7 + 12.5 + 21) = 16.12 (Std. formula)
4
1
u8 = (12.5 + 12.1 + 6.2 + 13.7) = 11.12 (Std. formula)
4

Dr. Shantha Kumari.K. AJIET, Mangaluru


Lecture Notes - 21MAT31, Module 4 - Numerical Solution of PDE Page 7

Now we carry out the iteration process using the Standard formula:

(n+1) 1 h (n) (n)


i
u1 = 0 + 11.1 + u4 + u2
4
(n+1) 1 h (n+1) (n) (n)
i
u2 = u1 + 17 + u5 + u3
4
(n+1) 1 h (n+1)
i
(n)
u3 = u2 + 19.7 + u6
+ 21.9
4
(n+1) 1 h (n+1) (n) (n)
i
u4 = u1 + 19.7 + u7 + u5
4
(n+1) 1 h (n+1) (n+1) (n) (n)
i
u5 = u4 + u2 + u8 + u6
4
(n+1) 1 h (n+1) (n+1) (n)
i
u6 = u5 + u3 + u9 + 21
4
(n+1) 1h 
(n+1) (n)
i
u7 = 0 + u4 + 8.7 + u8
4
(n+1) 1 h (n+1) (n+1) (n)
i
u8 = u7 + u5 + 12.1 + u9
4
(n+1) 1 h (n+1) (n)
i
u9 = u8 + u6 + 12.8 + 17
4
IET
First iteration (put n = 0, in the above results)

(1) 1 (o) (o)


 1
u1 = 0 + 11.1 + u4 + u2 = (0 + 11.1 + 6.52 + 13.55) = 7.79
4 4
(1) 1
u2 = (7.79 + 17 + 12.5 + 17.28) = 13.64
4
1
AJ

(1)
u3 = (13.64 + 19.7 + 16.12 + 21.9) = 12.84
4
(1) 1
u4 = (0 + 7.79 + 6.15 + 12.5) = 6.61
4
(1) 1
u5 = (6.61 + 13.64 + 11.12 + 16.12) = 11.88
4
(1) 1
u6 = (11.88 + 17.84 + 13.65 + 21) = 16.09
4
(1) 1
u7 = (0 + 6.61 + 8.7 + 11.12) = 6.61
4
(1) 1
u8 = (6.61 + 11.88 + 12.1 + 13.65) = 11.06
4
(1) 1
u9 = (11.06 + 16.09 + 12.8 + 17) = 12.238
4

Dr. Shantha Kumari.K. AJIET, Mangaluru


Lecture Notes - 21MAT31, Module 4 - Numerical Solution of PDE Page 8

Second iteration ( put n = 1)

(2) 1
u1 = (0 + 11.1 + 6.61 + 13.64) = 7.84
4
(2) 1
u2 = (7.84 + 17 + 11.88 + 17.84) = 16.64
4
(2) 1
u3 = (13.64 + 19.7 + 16.09 + 21.9) = 17.83
4
(2) 1
u4 = (0 + 7.84 + 6.61 + 11.88) = 6.58
4
(2) 1
u5 = (6.58 + 13.64 + 11.06 + 16.09) = 11.84
4
(2) 1
u6 = (11.84 + 17.83 + 14.24 + 21) = 16.23
4
(2) 1
u7 = (0 + 6.58 + 8.7 + 11.06) = 6.58
4
(2) 1
u8 = (6.58 + 11.84 + 12.1 + 14.24) = 11.19
4
(2) 1
u9 = (11.19 + 16.23 + 12.8 + 17) = 14.30
4
IET
Third iteration (put n = 2 )

(3) 1
u1 = (0 + 11.1 + 6.58 + 13.64) = 7.83
4
(3) 1
u2 = (7.83 + 17 + 11.84 + 17.83) = 13.637
4
1
AJ

(4)
u3 = (13.63 + 19.7 + 16.23 + 21.9) = 17.86
4
(3) 1
u4 = (0 + 7.83 + 6.58 + 11.84) = 6.56
4
(3) 1
u5 = (6.56 + 13.63 + 11.19 + 16.23) = 11.90
4
(3) 1
u6 = (11.90 + 17.86 + 14.30 + 21) = 16.27
4
(3) 1
u7 = (0 + 6.56 + 8.7 + 11.19) = 6.61
4
(3) 1
u8 = (6.61 + 11.90 + 12.1 + 14.30) = 11.23
4
(3) 1
u9 = (11.23 + 16.27 + 12.8 + 17) = 14.32
4

Dr. Shantha Kumari.K. AJIET, Mangaluru


Lecture Notes - 21MAT31, Module 4 - Numerical Solution of PDE Page 9

Similarly,
(4) (4) (4) (4) (4) (4)
u1 = 7.82, u2 = 13.65, u3 = 17.88, u4 = 6.58, u5 = 11.94, u6 = 16.28,
(4) (4) (4)
u7 = 6.63, u8 = 11.25, u9 = 14.33
(5) (5) (5) (5) (5) (5)
u1 = 7.83, u2 = 13.66, u3 = 17.89, u4 = 6.50, u5 = 11.95, u6 = 16.29,
(5) (5) (5)
u7 = 6.64, u8 = 11.25, u9 = 14.34

Problem 3. Given the values of u(x, y) on the boundary of the square in the Fig., evaluate the
function u(x, y) satisfying the Laplace equation ∇2 u = 0 at the pivotal points of this figure.

IET
AJ

Solution : To get the initial values of u1 , u2 , u3 , u4 , we assume u4 = 0. Then


1
u1 = 4
(1000 + 0 + 1000 + 2000) = 1000 (Diag. formula)
1
u2 = 4
(1000 + 500 + 1000 + 0) = 625 (Std. formula)
1
u3 = 4
(2000 + 0 + 1000 + 500) = 875 (Std. formula)
1
u4 = 4
(875 + 0 + 625 + 0) = 375 (Std. formula)

We carry out the successive iterations, using the formulae

(n+1) 1h (n) (n)


i
u1 = 2000 + u2 + 1000 + u3
4
(n+1) 1h (n+1) (n)
i
(n+1) 1h (n) (n+1)
i
u2 = u1 + 500 + 1000 + u4 u3 = 2000 + u4 + u1 + 500
4 4
(n+1) 1 h (n+1) (n+1)
i
u4 = u3 + 0 + u2 +0
4

Dr. Shantha Kumari.K. AJIET, Mangaluru


Lecture Notes - 21MAT31, Module 4 - Numerical Solution of PDE Page 10

First iteration: (put n = 0 )


(1) 1
u1 = (2000 + 625 + 1000 + 875) = 1125
4
1
u2 (1) = (1125 + 500 + 1000 + 375) = 750
4
(1) 1
u3 = (2000 + 375 + 1125 + 500) = 1000
4
(1) 1
u4 = (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
T
Third iteration: (put n = 2 )
IE
(3) 1
u1 = (2000 + 782 + 1000 + 1032) ≈ 1204
4
(3) 1
u2 = (1204 + 500 + 1000 + 454) ≈ 789
4
AJ

(3) 1
u3 = (2000 + 454 + 1204 + 500) ≈ 1040
4
(3) 1
Similarly, u4 = (1040 + 0 + 789 + 0) ≈ 458
4
(4) (4) (4) (4)
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 fifth iteration values. Hence u1 =
1208, u2 = 792, u3 = 1042 and u4 = 458.

Problem 4. Solve the elliptic equation uxx + uyy = 0 for the square mash of Figure with boundary
values as shown.

Dr. Shantha Kumari.K. AJIET, Mangaluru


Lecture Notes - 21MAT31, Module 4 - Numerical Solution of PDE Page 11

Solution. Let u1 , u2 , . . . , u9 be the values of u at the interior mesh-points. Since the boundary
values of u are symmetrical about AB.
T
∴ u7 = u1 , u8 = u2 , u9 = u3 . Also the values of u being symmetrical about CD, u3 = u1 ,
u6 = u4 , u9 = u7 Thus it is sufficient to find the values u1 , u2 , u4 and u5 . Now we find their
IE
initial value in the following order:
1
u5 = (2000 + 2000 + 1000 + 1000) = 1500 (Std. formula)
4
AJ

1
u1 = (0 + 1500 + 1000 + 2000) = 1125 (Diag. formula)
4
1
u2 = (1125 + 1125 + 1000 + 1500) ≈ 1188 (Std. formula)
4
1
u4 = (2000 + 1500 + 1125 + 1125) ≈ 1438 (Std. formula)
4
We carry out the iteration process using the formulae:

(n+1) 1h (n) 1
(n)
i
u1 = 1000 + u2 + 500 + u4
= [1500 + u2 + u4 ]
4 4
(n+1) 1 h (n+1) (n) (n)
i 1
u2 = u1 + u1 + 1000 + u5 = [1000 + 2u1 + u5 ]
4 4
(n+1) 1h (n) (n+1) (n)
i 1
u4 = 2000 + u5 + u1 + u1 = [2000 + 2u1 + u5 ]
4 4
(n+1) 1 h (n+1) (n) (n+1) (n)
i 1
u5 = u4 + u4 + u2 + u2 = [2u2 + 2u4 ]
4 4

Dr. Shantha Kumari.K. AJIET, Mangaluru


Lecture Notes - 21MAT31, Module 4 - Numerical Solution of PDE Page 12

iteration u1 = u2 = u4 = u5 =
1 1 1 1
number 4
[1500 + u2 + u4 ] 4
[1000 + 2u1 + u5 ] 4
[2000 + 2u1 + u5 ] 4
[2u2 + 2u4 ]
0 1125 1188 1438 1500
1 1032 1141 1391 1266
2 1088 1069 1321 1195
3 973 1035 1288 1162
4 956 1019 1269 1144
5 947 1010 1260 1135
6 942 1005 1255 1130
7 940 1003 1253 1128
8 939 1002 1252 1127
9 939 1001 1251 1126

Problem 5. Solve ∇2 u = 0 in the square region bounded by the co ordinate axes and the lines
x = 4, y = 4 with the boundary conditions given by the analytical expressions,
(i) u(0, y) = 0 for 0 ≤ y ≤ 4
(ii) u(4, y) = 12 + y for 0 ≤ y ≤ 4
(iii) u(x, 0) = 3x for 0 ≤ x ≤ 4
IET
(iv) u(x, 4) = x2 for 0 ≤ x ≤ 4
Also employ Liebmann’s iteration process to compute the second iterative values of u(x, y) correct
to two decimal places.

2 2
Solution : We have ∇2 u = 0 represented by ∂∂xu2 + ∂∂yu2 = 0 in two dimensions. We shall divide
the square region into 16 squares of side one unit.
AJ

We shall derive the values of u(x, y) on the boundary from the given expressions. (i) u(0, y) =
0⇒
u(0, 1) = 0 = u(0, 2) = u(0, 3) = u(0, 4)
(ii) u(4, y) = 12 + y ⇒ u(4, 0) = 12; u(4, 1) = 13;

u(4, 2) = 14; u(4, 3) = 15; u(4, 4) = 16

(iii) u(x, 0) = 3x ⇒ u(0, 0) = 0; u(1, 0) = 3;

u(2, 0) = 6; u(3, 0) = 9; u(4, 0) = 12

(iv) u(x, 4) = x2 ⇒ u(0, 4) = 0; u(1, 4) = 1 :

u(2, 4) = 4; u(3, 4) = 9; u(4, 4) = 16.

We shall represent these values on the square region and let u1 , u2 , · · · u9 be the interior mesh points
of the region.

Dr. Shantha Kumari.K. AJIET, Mangaluru


Lecture Notes - 21MAT31, Module 4 - Numerical Solution of PDE Page 13

u5 is located at the centre of the region.


1
∴ u5 = (0 + 14 + 4 + 6) = 6 by applying S.F
4
Next we apply D.F to compute u7 , u9 , u1 , u3
1 1
u7 = (0 + 6 + 0 + 6) = 3; u9 = (6 + 14 + 6 + 12) = 9.5
4 4
1 1
u1 = (0 + 4 + 0 + 6) = 2.5; u3 = (6 + 16 + 4 + 14) = 10
4 4
IET
Now we shall compute u2 , u4 , u6 , u8 by S.F
1
u2 = (2.5 + 10 + 4 + 6) = 5.625
4
1
u4 = (0 + 6 + 2.5 + 3) = 2.875
4
AJ

1
u6 = (6 + 14 + 10 + 9.5) = 9.875
4
1
u8 = (3 + 9.5 + 6 + 6) = 6.125
4
These values are regarded as the initial approximations to commence the Liebmann’s iterative process
for greater accuracy. We compute ui (i = 1 to 9) in the serial order by using the latest iterative value
on hand by applying the standard five point formula only. First iteration
1
u1 = (0 + 5.625 + 1 + 2.875) = 2.375
4
1
u2 = (2.375 + 10 + 4 + 6) = 5.59375
4
1
u3 = (5.59375 + 15 + 9 + 9.875) = 9.8671875
4

Dr. Shantha Kumari.K. AJIET, Mangaluru


Lecture Notes - 21MAT31, Module 4 - Numerical Solution of PDE Page 14

1
u4 = (0 + 6 + 2.375 + 3) = 2.84375
4
1
u5 = (2.84375 + 9.875 + 5.59375 + 6.125) = 6.109375
4
1
u6 = (6.109375 + 14 + 9.8671875 + 9.5) = 9.8691406
4
1
u7 = (0 + 6.125 + 2.84375 + 3) = 2.9921875
4
1
u8 = (2.99218i5 + 9.5 + 6.109375 + 6) = 6.1503906
4
1
u9 = (6.1503906 + 13 + 9.8691406 + 9) = 9.5048828
4
Thus we have the first iterative values correct to three decimal places

u1 = 2.375, u2 = 5.594, u3 = 9.867, u4 = 2.844, u5 = 6.109


u6 = 9.869, u7 = 2.992, u8 = 6.150, u9 = 9.505

Second iteration
1
u1 = (0 + 5.594 + 1 + 2.844) = 2.36
IET
4
1
u2 = (2.36 + 9.867 + 4 + 6.109) = 5.584
4
1
u3 = (5.584 + 15 + 9 + 9.869) = 9.863
4
1
u4 = (0 + 6.109 + 2.36 + 2.992) = 2.865
4
AJ

1
u5 = (2.865 + 9.869 + 5.586 + 6.150) = 6.118
4
1
u6 = (6.118 + 14 + 9.864 + 9.506) = 9.872
4
1
u7 = (0 + 6.150 + 2.867 + 3) = 3.004
4
1
u8 = (3.004 + 9.505 + 6.118 + 6) = 6.157
4
1
u9 = (6.157 + 13 + 9.872 + 9) = 9.507
4

u1 = 2.36, u2 = 5.58, u3 = 9.86, u4 = 2.87, u5 = 6.12


u6 = 9.87, u7 = 3, u8 = 6.16, u9 = 9.51

4.4 Practice Problems:

1. Solve uxx + uyy = 0 fo the following square mesh with boundary values as shown in the
following figure (Model 2022)

Dr. Shantha Kumari.K. AJIET, Mangaluru


Lecture Notes - 21MAT31, Module 4 - Numerical Solution of PDE Page 15

2. Solve uxx + uyy = 0 fo the following square mesh with boundary values as shown in the
following figure (Model 2022)

IET
AJ

3. Solve uxx + uyy = 0 fo the following square mesh with boundary values as shown in the
following figure

4. Solve the elliptic equation uxx + uyy = 0 for the following square mesh with boundary values
as shown. Find the first iterative values of ui (i = 1 to 9) to the nearest integer.

Dr. Shantha Kumari.K. AJIET, Mangaluru


Lecture Notes - 21MAT31, Module 4 - Numerical Solution of PDE Page 16

5. Solve uxx + uyy = 0 fo the following square mesh with boundary values as shown in the
following figure

IET
Ans : u1 = 45.825, u2 = 40.4, u3 = 22.9, u4 = 15.825

6. Solve uxx + uyy = 0 fo the following square mesh with boundary values as shown in the
following figure
AJ

Ans :u1 = 1, u2 = 2.5, u3 = 0.5, u4 = 1

4.5 Numerical Solution of one dimensional Heat equation :

Consider the heat equation


∂u ∂ 2u
= c2
∂t ∂x2
TO solve this numerically, we consider a rectangular mesh in the x − t plane with spacing h along x
direction and k along time t direction. Denoting a mesh point (x, t) = (ih, jk) as simply i, j, we

Dr. Shantha Kumari.K. AJIET, Mangaluru


Lecture Notes - 21MAT31, Module 4 - Numerical Solution of PDE Page 17

have
ui,j+1 = αui−1,j + (1 − 2α)ui,j + αui+1,j

where α = kc2 /h2 is the mesh ratio parameter.


This formula is called the Schmidt explicit formula which is valid only for 0 < α ≤ 21 .
This formula enables us to determine the value of u at the (i, j + 1)th mesh point in terms of the
known function values at the points xi−1 , xi and xi+1 at the instant tj . is called the Schmidt explicit
formula which is valid only for 0 < α ≤ 12 .

IET
In particular when α = 21 , above formula reduces to

1
ui,j+1 = (ui−1,j + ui+1,j )
2
AJ

which is known as Bendre-Schmidt formula.

Crank-Nicolson method:

The Crank-Nicolson formula to solve heat equation is given by

−αui−1,j+1 + (2 + 2α)ui,j+1 − αui+1,j+1 = αui−1,j + (2 − 2α)ui,j + αui+1,j (∗∗)

where α = kc2 /h2 .


Its computational model is given in the following figure.

Dr. Shantha Kumari.K. AJIET, Mangaluru


Lecture Notes - 21MAT31, Module 4 - Numerical Solution of PDE Page 18

Clearly the left side of the above formula (**) contains three unknown values of u at the (j + 1)th
level while all the three values on the right are known values at the jth level.
2
Problem 6. Find the numerical solution of the parabolic equation ∂∂xu2 = 2 ∂u
∂t
when u(0, t) = 0 =
u(4, t) and u(x, 0) = x(4 − x) by taking h = 1 find the values up to t = 5.

Sol : The standard form of the one dimensional heat equation is ut = c2 uxx and the given equation
IET
can be put in the form ut = (1/2)uxx
∴ c2 = 1/2. Since h = 1, k = h2 /2c2 = 1
The values of x in 0 ≤ x ≤ 4 with h = 1 are 0, 1, 2, 3, 4 and the values of t with k = 1 are
0, 1, 2, 3, 4, 5.
We have the following initial table wherein the values in the first and last column are zero since
u(0, t) = 0, u(4, t) = 0
AJ

Consider the initial condition u(x, 0) = x(4 − x) ∴ u1,0 = u(1, 0) = 3; u2,0 = 4; u3,0 = 3
(First row in the table is completed) Now we consider the relation
1
ui,j+1 = [ui−1,j + ui+1,j ]
2
Using this formula for i = 1, 2, 3 and j = 0, 1, 2, 3, 4 we get the following table containing re-
quired values of ui,j
t\x x=0 x=1 x=2 x=3 x=4
t=0 0 3 4 3 0
t=1 0 2 3 2 0
t=2 0 1.5 2 1.5 0
t=3 0 1 1.5 1 0
t=4 0 0.75 1 0.75 0
t=5 0 0.5 0.75 0.5 0

Problem 7. Solve numerically the equation ut = uxx Subject to the conditions u(0, t) = 0 =
u(1, t), t ≥ 0 and u(x, 0) = sin πx, 0 ≤ x ≤ 1. Carryout computations for two levels taking
h = 1/3 and k = 1/36.

Dr. Shantha Kumari.K. AJIET, Mangaluru


Lecture Notes - 21MAT31, Module 4 - Numerical Solution of PDE Page 19

Sol : We have c2 = 1, h = 1/3, k = 1/36 ∴ α = kc2 /h2 = 1/4


Since h = 1/3, the values of x in 0 ≤ x ≤ 1 are x0 = 0, x1 = 1/3, x2 = 2/3 & x3 = 1.

u(0, t) = 0 ⇒ u0,0 = u0,1 = u0,2 = · · · = 0


u(1, t) = 0 ⇒ u3,0 = u3,1 = u3,2 = · · · = 0
Also, u(x, 0) = sin πx and hence we have

u (x1 , 0) = u1,0 = sin(π/3) = 0.866


u (x2 , 0) = u2,0 = sin(2π/3) = 0.866

Since α = 1/4, we shall use Schmidt explicit formula given by

ui,j+1 = αui−1,j + (1 − 2α)ui,j + αui+1,j

i.e.  
1 1 1 1 1
ui,j+1 = ui−1,j + ui,j + ui+1,j = ui−1,j + 2ui,j + ui+1,j
4 2 4 4 4
We shall compute u1,1 , u2,1 (first level) and u1,2 , u2,2 (second level) by using the above formula.
IET
Thus we have,
1
u1,1 = [u0,0 + 2u1,0 + u2,0 ] = 0.6495
4
1
u2,1 = [u1,0 + 2u2,0 + u3,0 ] = 0.6495
4
1
u1,2 = [u0,1 + 2u1,1 + u2,1 ] = 0.487125
4
AJ

1
u2,2 = [u1,1 + 2u2,1 + u3,1 ] = 0.487125
4
Problem 8. Solve the heat conduction problem

∂u ∂ 2u
=
∂t ∂x2
subject to the conditions u(x, 0) = sin πx, 0 ≤ x ≤ 1, and u(0, t) = u(1, t) = 0. Use
Bender-Schmidt’s formula to compute the value of u(0.6, 0.04).Take h = 0.2 and α 21

Here c2 = 1 ⇒ c = 1
Given that h = 0.2 and α = 12
2
Then α = kc h2
⇒ 12 = 0.04k
⇒ k = 21 (0.04) = 0.02.
The initial values of u are

u0,0 = 0, u1,0 = 0.5878, u2,0 = 0.9510,


u3,0 = 0.9510, u4,0 = 0.5878, u5,0 = 0.

Dr. Shantha Kumari.K. AJIET, Mangaluru


Lecture Notes - 21MAT31, Module 4 - Numerical Solution of PDE Page 20

1
Using the Bendre-Schmidt formula ui,j+1 = 2
[ui−1,j + ui+1,j ] we have

1 1
u1,1 = (0.9510) = 0.4755, u2,1 = (0.5878 + 0.9510) = 0.7694,
2 2
u3,1 = 0.7694, u4,1 = 0.4755.

Also,
1
u1,2 = (0.7694) = 0.3847, u2,2 = 0.62245,
2
u3,2 = 0.62245, u4,2 = 0.3847.
Therefore, u(0.6, 0.04) = u3,2 = 0.6224.

Problem 9. Find the values of u(x, t) satisfying the parabolic equation ut = 4uxx and the bound-
2
ary conditions u(0, t) = 0 = u(8, t) and u(x, 0) = 4x − x2 at the points x = i : i =
0, 1, 2, . . . , 8 and t = 8j : j = 0, 1, 2, 3, 4, 5

Sol : Here c2 = 4, h = 1 and k = 1/8. Then α = c2 k/h2 = 1/2.


∴ We have Bendre-Schmidt’s recurrence relation
ui,j+1 = 1/2 (ui−1,j + u =)
IET
Now since u(0, t) = 0 = u(8, t)
∴ u0,j = 0 and u8,j = 0 for all values of j,
i.e., the entries in the first and last column are zero.
Since u(x, 0) = 4x − (1/2)x2
1
i2
AJ

∴ ui,0 = 4i −
2
= 0, 3.5, 6, 7.5, 8, 7.5, 6, 3.5 for i = 0, 1, 2, 3, 4, 5, 6, 7

at t = 0
These are the entries of the first row.
The entries for second and higher rows (i.e. t = 1/8 to t = 5/8) are given by using Bendre-Schmidt
formula.

2
Problem 10. Solve ∂u
∂t
= ∂∂2 xu2 in 0 < x < 5, t ≥ 0 given that u(x, 0) = 20, u(0, t) =
0, u(5, t) = 100. Compute u for the time-step with h = 1 by Crank-Nicholson method.

Dr. Shantha Kumari.K. AJIET, Mangaluru


Lecture Notes - 21MAT31, Module 4 - Numerical Solution of PDE Page 21

Solution. Here c2 = 1 and h = 1. Taking α ( i.e., c2 k/h) = 1, we get k = 1 Also we have

Then Crank-Nicholson formula becomes

4ui,j+1 = ui−1,j+1 + ui+1,j+1 + ui−1,j + ui+1,j


4u1 = 0 + 20 + 0 + u2 i.e. 4u1 − u2 = 20 · · · (1)
4u2 = 20 + 20 + u1 + u3 i.e. 4u1 − 4u2 + u3 = −40 · · · (2)
4u3 = 20 + 20 + u2 + u4 i.e. u2 − 4u3 + u4 = −40 · · · (3)
4u4 = 20 + 100 + u3 + 100 i.e. 4u3 − 4u4 + = −220 · · · (4)

Now (1) − 4(2) gives 15u2 − 4u3 = 180 · · · (5)


4(3) + (4) gives 4u2 − 15u3 = −380 · · · (6)
IET
Then 15(5) − 4(6) gives 209u2 = 4220 i.e. u2 = 20.2
From (5), we get
From (1), 4u1 = 20 + 20.2 i.e. u1 = 10.05
From (4), 4u4 = 220 + 30.75 i.e. u4 = 62.69
4u3 = 15 × 20.2 − 180 i.e. u3 = 30.75
Thus the required values are 10.05, 20.2, 30.75 and 62.68.
AJ

2
Problem 11. Solve the equation ∂u
∂t
= ∂∂xu2 subject to the conditions u(x, 0) = sin πx, 0 ≤ x ≤
1
1, u(0, t) = u(1, t) = 0, Carry out computations for two levels, taking h = 13 and k = 36

Sol : Here c2 = 1, h = 13 = 0.2 and k = 36 1


2
Hence α = kc h2
= 14
Since α 6= 12 , we shall use Schmidt explicit formula.

ui,j+1 = αui−1,j + (1 − 2α)ui,j + αui+1,j


1
becomes ui,j+1 = [ui−1,j + 2ui,j + ui+1,j ]
4
For i = 1, 2; j = 0 :
1 1 √
u1,1 = [u0,0 + 2u1,0 + u2,0 ] = (0 + 2 ×
3/2 + 3/2) = 0.65
4 4
1 1 √ √
u2,1 = [u1,0 + 2u2,0 + u3,0 ] = ( 3/2 + 2 × 3/2 + 0) = 0.65
2 4

Dr. Shantha Kumari.K. AJIET, Mangaluru


Lecture Notes - 21MAT31, Module 4 - Numerical Solution of PDE Page 22

For i = 1, 2; j = 1 :
1
u1,2 = (u0,1 + 2u1,1 + u2,1 ) = 0.49
4
1
u2,2 = (u1,1 + 2u2,1 + u3,1 ) = 0.49
4

4.6 Numerical Solution of one dimensional Wave equation :

We seek the numerical solution of the wave equation

c2 uxx = utt . . . (i)

subject to the boundary conditions


u(0, t) = 0 . . . (ii)
u(`, t) = 0 . . . (iii)
and the initial conditions,
u(x, 0) = f (x) . . . (iv)
IET
ut (x, 0) = 0 . . . (v)
If we denote hk = λ and select λ such that 1 − c2 λ2 = 0
ie., 1 − c2 (k2 /h2 ) = 0 or k2 = h2 /c2 ⇒ k = h/c
Then the formula to find ui,j+1 is given by
AJ

ui,j+1 = ui−1,j + ui+1,j − ui,j−1

This is called the explicit formula for the solution of the wave equation.
2 2
Problem 12. Solve the wave equation ∂∂tu2 = 4 ∂∂xu2 Subject to u(0, t) = 0 = u(4, t), ut (x, 0) =
0 and u(x, 0) = x(4 − x) by taking h = 1, k = 0.5 up to four steps.

 Step size of x : h = 1; Step size of t : k = 0.5 Since 0 ≤ x ≤ 4, the points of division


are 0, 1, 2, 3, 4. Since k = 0.5, the values corresponding to t upto four steps are 0, 0.5, 1, 1.5
and 2 . We have the following initial table. The values in the first and last column are zero since
u(0, t) = 0 = u(4, t)
t\x x0 = 0h x1 = 1h x2 = 2h x3 = 3h x4 = 4h
t0 = 0k = 0 0 1 2 3 4
t1 = 1k = 0.5 u0,0 = 0 u1,0 u2,0 u3,0 u4,0 = 0
t2 = 2k = 1 u0,1 = 0 u1,1 u2,1 u3,1 u4,1 = 0
t3 = 3k = 1.5 u0,2 = 0 u1,2 u2,2 u3,2 u4,2 = 0
t4 = 4k = 2 u0,3 = 0 u1,3 u2,3 u3,3 u4,3 = 0
u0,4 = 0 u1,4 u2,4 u3,4 u4,4 = 0

Dr. Shantha Kumari.K. AJIET, Mangaluru


Lecture Notes - 21MAT31, Module 4 - Numerical Solution of PDE Page 23

Now consider u(x, 0) = x(4 − x)

∴ u1,0 = u(1, 0) = 3; u2,0 = u(2, 0) = 4; u3,0 = 3

(The first row(i.e. 0th level) in the table is completed ) The values in the 2nd row (i.e. level 1) are
obtained by using
1
Next consider ui,1 = [ui−1,0 + ui+1,0 ]
2
1 1
∴ u1,1 = [u0,0 + u2,0 ] = (0 + 4) = 2
2 2
1 1
u2,1 = [u1,0 + u3,0 ] = (3 + 3) = 3
2 2
1 1
u3,1 = [u2,0 + u4,0 ] = (4 + 0) = 2
2 2

We now consider the explicit formula to find the remaining values in the table.

ui,j+1 = ui−1,j + ui+1,j − ui,j−1

u1,2 = u0,1 + u2,1 − u1,0 = 0 + 3 − 3 = 0


T
u2,2 = u1,1 + u3,1 − u2,0 = 2 + 2 − 4 = 0
IE
u3,2 = u2,1 + u4,1 − u3,0 = 3 + 0 − 3 = 0
(The third row is completed)

u1,3 = u0,2 + u2,2 − u1,1 = 0 + 0 − 2 = −2


AJ

u2,3 = u1,2 + u3,2 − u2,1 = 0 + 0 − 3 = −3


u3,3 = u2,2 + u4,2 − u3,1 = 0 + 0 − 2 = −2

(The fourth row is completed)

u1,4 = u0,3 + u2,3 − u1,2 = 0 − 3 − 0 = −3


u2,4 = u1,3 + u3,3 − u2,2 = −2 − 2 − 0 = −4
u3,4 = u2,3 + u4,3 − u3,2 = −3 + 0 − 0 = −3

(The last rowe is completed) Thus the required values of ui,j are tabulated.
t\x x0 = 0h x1 = 1h x2 = 2h x3 = 3h x4 = 4h
t0 = 0k = 0 0 1 2 3 4
t1 = 1k = 0.5 0 3 4 3 0
t2 = 2k = 1 0 2 3 2 0
t3 = 3k = 1.5 0 0 0 0 0
t4 = 4k = 2 0 −2 −3 −2 0
t5 = 5k = 2.5 0 −3 −4 −3 0

Dr. Shantha Kumari.K. AJIET, Mangaluru


Lecture Notes - 21MAT31, Module 4 - Numerical Solution of PDE Page 24

Problem 13. Solve numerically uxx = 0.0625utt Subject to the conditions u(0, t) = 0 =
u(5, t), u(x, 0) = x2 (x − 5) by taking h = 1 for 0 ≤ t ≤ 1

The wave equation in the standard form is c2 uxx = utt


and hence the given equation be put in the form (1/0.0625)uxx = utt
That is, 16uxx = utt where c2 = 16 or c = 4
Since h = 1, we have k = h/c = 1/4 = 0.25
Step size of x : h = 1 where 0 ≤ x ≤ 5
Step size of t : k = 0.25 where 0 ≤ t ≤ 1 as required.
∴ values of x are 0, 1, 2, 3, 4, 5
values of t are 0, 0.25, 0.5, 0.75, 1
We have the following initial table. The values in the first and last column are zero since u(0, t) =
0 = u(5, t)
t\x x0 = 0h x1 = 1h x2 = 2h x3 = 3h x4 = 4h x5 = 5h
t0 = 0k = 0 0 1 2 3 4 5
t1 = 1k = 0.25 u0,0 = 0 u1,0 u2,0 u3,0 u4,0 u5,0 = 0
t2 = 2k = 0.5 u0,1 = 0 u1,1 u2,1 u3,1 u4,1 u5,1 = 0
IET
t3 = 3k = 0.75 u0,2 = 0 u1,2 u2,2 u3,2 u4,2 u5,2 = 0
t4 = 4k = 1 u0,3 = 0 u1,3 u2,3 u3,3 u4,3 u5,3 = 0
t5 = 5k = 1.25 u0,4 = 0 u1,4 u2,4 u3,4 u4,4 u5,4 = 0
2
Now consider u(x, 0) = x (x − 5)

∴ u1,0 = u(1, 0) = −4; u2,0 = −12; u3,0 = −18; u4,0 = −16


AJ

(The first row(i.e. 0th level) in the table is completed ) The values in the 2nd row (i.e. level 1) are
obtained by using
1
Next consider ui,1 = [ui−1,0 + ui+1,0 ]
2
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

Dr. Shantha Kumari.K. AJIET, Mangaluru


Lecture Notes - 21MAT31, Module 4 - Numerical Solution of PDE Page 25

We now consider the explicit formula to find the remaining values in the table.

ui,j+1 = ui−1,j + ui+1,j − ui,j−1


∴ u1,2 = u0,1 + u2,1 − u1,0 = 0 − 11 + 4 = −7
u2,2 = u1,1 + u3,1 − u2,0 = −6 − 14 + 12 = −8
u3,2 = u2,1 + u4,1 − u3,0 = −11 − 9 + 18 = −2
u4,2 = u3,1 + u5,1 − u4,0 = −14 + 0 + 16 = 2

(Third row in the table is completed)

u1,3 = u0,2 + u2,2 − u1,1 = 0 − 8 + 6 = −2


u2,3 = u1,2 + u3,2 − u2,1 = −7 − 2 + 11 = 2
u3,3 = u2,2 + u4,2 − u3,1 = −8 + 2 + 14 = 8
u4,3 = u3,2 + u5,2 − u4,1 = −2 + 0 + 9 = 7

(Fourth row in the table is completed)

u1,4 = u0,3 + u2,3 − u1,2 = 0 + 2 + 7 = 9


IET
u2,4 = u1,3 + u3,3 − u2,2 = −2 + 8 + 8 = 14
u3,4 = u2,3 + u4,3 − u3,2 = 2 + 7 + 2 = 11
u4,4 = u3,3 + u5,3 − u4,2 = 8 + 0 − 2 = 6

(Fifth row in the table is completed)


Thus the required values of ui,j are tabulated.
AJ

t\x x0 = 0h x1 = 1h x2 = 2h x3 = 3h x4 = 4h x5 = 5h
t0 = 0k = 0 x=0 x=1 x=2 x=3 x=4 x=5
t1 = 1k = 0.25 0 −4 −12 −18 −16 0
t2 = 2k = 0.5 0 −6 −11 −14 −9 0
t3 = 3k = 0.75 0 −7 −8 −2 2 0
t4 = 4k = 1 0 −2 2 8 7 0

Problem 14. The transverse displacement u of a point at a distance x from one end and at any time
t of a vibrating string satisfies the equation utt = (
25uxx , with the boundary conditions u(x, t) =
20x, 0≤x≤1
u(5, t) = 0 and the initial conditions u(x, 0) = and ut (x, 0) = 0.
5(5 − x), 1 ≤ x ≤ 5
Solve this equation numerically up to t = 5 taking h = 1, k = 0.2.

Sol : Comparing the wave equation c2 uxx = ut+ with the given equation 25uxx = ut1 , we have
c2 = 25 or c = 5. Also k = h/c = 1/5 = 0.2
Since h = 1, the values of x in 0 ≤ x ≤ 5
i.e. 0, 1, 2, 3, 4, 5 and the values of t are 0, 0.2, 0.4, 0.6, 0.8, 1

Dr. Shantha Kumari.K. AJIET, Mangaluru


Lecture Notes - 21MAT31, Module 4 - Numerical Solution of PDE Page 26

t\x x0 = 0h x1 = 1h x2 = 2h x3 = 3h x4 = 4h x5 = 5h
t0 = 0k = 0 0 1 2 3 4 5
t1 = 1k = 0.2 u0,0 = 0 u1,0 u2,0 u3,0 u4,0 u5,0 = 0
t2 = 2k = 0.4 u0,1 = 0 u1,1 u2,1 u3,1 u4,1 u5,1 = 0
t3 = 3k = 0.6 u0,2 = 0 u1,2 u2,2 u3,2 u4,2 u5,2 = 0
t4 = 4k = 0.8 u0,3 = 0 u1,3 u2,3 u3,3 u4,3 u5,3 = 0
t5 = 5k = 1 u0,4 = 0 u1,4 u2,4 u3,4 u4,4 u5,4 = 0

20x ,
i 0≤x≤1
We have u(x, 0) =
5(5 − x), 1 ≤ x ≤ 5

u1,0 = u(1, 0) = 20, u2,0 = u(2, 0) = 5 × 3 = 15,



u3,0 = u(3, 0) = 5 × 2 = 10, u4,0 = u(4, 0) = 5

(First row in the table is completed)


1
Next consider ui,1 = [ui−1,0 + ui+1,0 ]
IET
2
1 1
∴ u1,1 = [u0,0 + u2,0 ] = (0 + 15) = 7.5
2 2
1 1
u2,1 = [u1,0 + u3,0 ] = (20 + 10) = 15
2 2
1 1
u3,1 = [u2,0 + u4,0 ] = (15 + 5) = 10
2 2
AJ

1 1
u4,1 = [u3,0 + u5,0 ] = (10 + 0) = 5
2 2

(Second row in the table is completed)


We now consider the explicit formula to find the remaining values in the table.

ui,j+1 = ui−1,j + ui+1,j − ui,j−1


∴ u1,2 = u0,1 + u2,1 − u1,0 = 0 + 15 − 20 = −5
u2,2 = u1,1 + u3,1 − u2,0 = 7.5 + 10 − 15 = 2.5
u3,2 = u2,1 + u4,1 − u3,0 = 15 + 5 − 10 = 10
u4,2 = u3,1 + u5,1 − u4,0 = 10 + 0 − 5

(Third row in the table is completed)

Dr. Shantha Kumari.K. AJIET, Mangaluru


Lecture Notes - 21MAT31, Module 4 - Numerical Solution of PDE Page 27

u1,3 = u0,2 + u2,2 − u1,1 = 0 + 2.5 − 7.5 = −5


u2,3 = u1,2 + u3,2 − u2,1 = −5 + 10 − 15 = −10
u3,3 = u2,2 + u4,2 − u3,1 = 2.5 + 5 − 10 = −2.5
u4,3 = u3,2 + u5,2 − u4,1 = 10 + 0 − 5 = 5
(Fourth row in the table is completed)

u1,4 = u0,3 + u2,3 − u1,2 = 0 − 10 + 5 = −5


u2,4 = u1,3 + u3,3 − u2,2 = −5 − 2.5 − 2.5 = −10
u3,4 = u2,3 + u4,3 − u3,2 = −10 + 5 − 10 = −15
u4,4 = u3,3 + u5,3 − u4,2 = −2.5 + 0 − 5 = −7.5

(Fifth row in the table is completed)

u1,5 = u0,4 + u2,4 − u1,3 = 0 − 10 + 5 = −5


u2,5 = u1,4 + u3,4 − u2,3 = −5 − 15 + 10 = −10
u3,5 = u2,4 + u4,4 − u3,3 = −10 − 7.5 + 2.5 = −15
IET
u4,5 = u3,4 + u5,4 − u4,3 = −15 + 0 − 5 = −20
(Last row in the table is completed)
Thus the required values of ui,j are tabulated.
t\x x0 = 0h x1 = 1h x2 = 2h x3 = 3h x4 = 4h x5 = 5h
t0 = 0k = 0 0 1 2 3 4 5
AJ

t1 = 1k = 0.2 0 20 15 10 5 0
t2 = 2k = 0.4 0 7.5 15 10 5 0
t3 = 3k = 0.6 0 −5 2.5 10 5 0
t4 = 4k = 0.8 0 −5 −10 −2.5 5 0
t5 = 5k = 1 0 −5 −10 −15 −20 0

Dr. Shantha Kumari.K. AJIET, Mangaluru

You might also like