Helm (2005) : Section 32.4: Parabolic Pdes
Helm (2005) : Section 32.4: Parabolic Pdes
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
Parabolic PDEs
32.4
Introduction
Second-order partial dierential equations (PDEs) may be classied as parabolic, hyperbolic or elliptic.
Parabolic and hyperbolic PDEs often model time dependent processes involving initial data.
In this Section we consider numerical solutions of parabolic problems.
Prerequisites
Before starting this Section you should . . .
review dierence methods for rst and second
derivatives ( 31.3)
Learning Outcomes
On completion you should be able to . . .
implement simple methods to obtain
approximate solutions of the heat diusion
equation
HELM (2005):
Section 32.4: Parabolic PDEs
45
www.ebookcraze.blogspot.com
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
1. Denitions
We begin by giving some denitions.
Suppose that u = u(x, t) satises the second order partial dierential equation
Au
xx
+ Bu
xt
+ Cu
tt
+ Du
x
+ Eu
t
+ Fu = G
in which A, . . . , G are given functions. This equation is said to be
parabolic if B
2
4AC = 0
hyperbolic if B
2
4AC > 0
elliptic if B
2
4AC < 0
These may look like rather abstract denitions at this stage, but we will see that equations of dierent
types give rise to mathematical models of dierent physical situations. In this Section we will consider
equations only of the parabolic type. The hyperbolic type is dealt with later in this Workbook and
the elliptic type is discussed in 33.
2. Motivation
Consider an example of the type seen in the earlier material concerning separable solutions of the
heat conduction equation. Suppose that u = u(x, t) is the temperature of a metal bar a distance x
from one end and at time t. For the sake of argument let us suppose that the metal bar has length
equal to and that the ends are held at constant temperatures u
L
at the left and u
R
at the right.
u
L
u
R
x
0
Figure 2
We also suppose that the temperature distribution at the initial time is known to be f(x), with
f(0) = u
L
and f() = u
R
so that the initial and boundary conditions do not give rise to a conict
at the ends of the bar at the initial time.
This physical situation may be modelled by
u
t
= u
xx
(0 < x < , t > 0)
u(0, t) = u
L
(t > 0)
u(, t) = u
R
(t > 0)
u(x, 0) = f(x) (0 < x < )
_
_
in which > 0 is a constant called the thermal diusivity or simply the diusivity of the metal.
If the bar is made of aluminium then = 0.86 cm
2
s
1
, and if made of copper then = 1.14 cm
2
s
1
.
Using separation of variables and Fourier series (neither of which are required for the remainder of this
Section) it can be shown that the solution to the above problem (in the case where u
L
= u
R
= 0) is
46 HELM (2005):
Workbook 32: Numerical Initial Value Problems
www.ebookcraze.blogspot.com
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
u(x, t) =
m=1
B
m
e
m
2
2
t/
2
sin(mx/), where B
m
=
2
_
0
f(s) sin(ms/) ds.
Now, let us be realistic. Any evaluation of u for particular choices of x and t must involve ap-
proximating the innite series that denes u (that is, just taking the rst few terms - and care is
required if we are to be sure that we have taken enough). Also, in each of the terms we retain in
the sum, we need to nd B
m
by integration. It is not surprising that computation of this procedure
is a common approach. So if we (eventually) resort to computation in order to nd u, why not start
with a computational approach?
(This is not to say that there is no value in the analytic solution involving the B
m
. The solution above
is of great value, but we simply observe here that there are times when a computational approach is
all we may end up needing.)
So, the aim of this Section is to derive methods for obtaining numerical solutions to parabolic
problems of the type above. In fact, it is sucient for our present purposes to restrict attention to
that particular problem.
3. Approximating partial derivatives
Earlier, in 31.3, we saw methods for approximating rst and second derivatives of a function
of one variable. We review some of that material here. If y = y(x) then the forward and central
dierence approximations to the rst derivative are:
dy
dx
y(x + x) y(x)
x
,
dy
dx
y(x + x) y(x x)
2x
and the central dierence approximation to the second derivative is:
d
2
y
dx
2
y(x + x) 2y(x) + y(x x)
(x)
2
in which x is a small x-increment. The quantity x is what we previously referred to as h, but it is
now convenient to use a notation which is more closely related to the independent variable (in this
case x). (Examples implementing the dierence approximations for derivatives can be found in
31.)
We now return to the subject of this Section, that of partial derivatives. The PDE u
t
= u
xx
involves
the rst derivative
u
t
and the second derivative
2
u
x
2
. We now adapt the ideas used for functions of
one variable to the present case involving u = u(x, t).
Let t be a small increment of t, then the partial derivative
u
t
may be approximated by:
u
t
u(x, t + t) u(x, t)
t
Let x be a small increment of x, then the partial derivative
2
u
x
2
may be approximated by:
2
u
x
u(x + x, t) 2u(x, t) + u(x x, t)
(x)
2
The two dierence approximations above are the ones we will use later in this Section. Example 14
below refers to these and others.
HELM (2005):
Section 32.4: Parabolic PDEs
47
www.ebookcraze.blogspot.com
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
Example 14
Consider the function u dened by
u(x, t) = sin(x
2
+ 2t)
Using increments of x = 0.004 and t = 0.04, and working to 8 decimal places,
approximate
(a) u
x
(2, 3) with a one-sided forward dierence
(b) u
xx
(2, 3) with a central dierence
(c) u
t
(2, 3) with a one-sided forward dierence
(d) u
t
(2, 3) with a central dierence.
Enter your approximate derivatives to 3 decimal places.
Solution
The evaluations of u we will need are u(x, t) = 0.54402111, u(x + x, t) = 0.55738933,
u(x x, t) = 0.53054047, u(x, t + t) = 0.60933532, u(x, t t) = 0.47522703. It follows
that
(a) u
x
(2, 3)
0.55738933 + 0.54402111
0.004
= 3.342
(b) u
xx
(2, 3)
0.55738933 + 2 0.54402111 0.53054047
0.004
2
= 7.026
(c) u
t
(2, 3)
0.60933532 + 0.54402111
0.04
= 1.633
(d) u
t
(2, 3)
0.60933532 + 0.47522703
2 0.04
= 1.676
to 3 decimal places. (Workings shown to 8 decimal places.)
4. An explicit numerical method for the heat equation
The approximations used above for approximating partial derivatives can now be applied in order to
derive a numerical method for solving the heat conduction problem
u
t
= u
xx
(0 < x < , t > 0)
u(0, t) = 0 (t > 0)
u(, t) = 0 (t > 0)
u(x, 0) = f(x) (0 < x < ).
In order to specify the numerical method we choose values for t and x and use these in approx-
imations of the two derivatives in the partial dierential equation. It is convenient to divide the
48 HELM (2005):
Workbook 32: Numerical Initial Value Problems
www.ebookcraze.blogspot.com
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
interval 0 < x < into equally spaced subintervals so, in eect, we choose a whole number J so
that x =
J
.
Key Point 15
In order to specify the numerical procedure for solving the heat conduction equation
u
t
=
2
u
x
2
we need to choose
t the time step
x the space step
t
2t
x 2x
x
t
n = 1
n = 2
n = 3
n = 4
j = 1 j = 2 j = 3
j = J1 j = J
x =
t
x
Figure 3
The diagram above shows the independent variables x and t at which we seek the function u. The
numerical solution we shall nd is a sequence of numbers which approximate u at a sequence of (x, t)
points.
HELM (2005):
Section 32.4: Parabolic PDEs
49
www.ebookcraze.blogspot.com
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
Key Point 16
The numerical approximations to u(x, t) that we will nd will be approximations to u at (x, t) values
where the horizontal and vertical lines cross in the above diagram (Figure 3).
The notation we use is that
u
n
j
u(j x , n t)
. .
numerical exact (i.e., unknown) solution
approximation evaluated at x = j x, t = n t
The idea is that the subscript j counts how many steps to the right we have taken from the origin
and the superscript n counts how many time-steps (up, on the diagram) we have taken. To say this
another way
the superscript counts up the t values
u
n
j
_
is said to be stable if the approximations u
n
j
do not grow in magnitude with n.
HELM (2005):
Section 32.4: Parabolic PDEs
57
www.ebookcraze.blogspot.com
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
(Of course, there are applications where the principal quantity of interest does grow with time, and
in these cases other denitions of stability are appropriate.)
The main stability result for the explicit scheme is proved in many textbooks on the subject, but for
this Workbook it is sucient to simply state it.
Key Point 20
The explicit scheme is stable if and only if
r
1
2
Writing this another way we see that the restriction on the time-step is that
t
x
2
2
Why is the stability constraint a problem?
In the above account it has been stated that the stability constraint is a severe restriction on the
time-step t. Here we discuss why this is the case.
For sake of argument let us take an example where = 1 and choose x =
1
10
. The stability
requirement insists that we must choose
t
1
2
x
2
=
1
200
,
which is much smaller than x. If we require an even smoother approximation in the x direction we
could halve x taking it to be equal to
1
20
. It is now necessary that
t
1
2
x
2
=
1
800
.
Decreasing x by a factor of 2 causes t to decrease by a factor of 4. The problem is that the upper
bound on t involves the square of x, which is likely to be very small.
The following method overcomes the requirement of tiny time-steps.
58 HELM (2005):
Workbook 32: Numerical Initial Value Problems
www.ebookcraze.blogspot.com
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
6. The Crank-Nicolson method
In the notation established for the explicit method, the so-called Crank-Nicolson scheme can be
written
u
n+1
j
= u
n
j
+
1
2
r
_
u
n
j1
2u
n
j
+ u
n
j+1
. .
+ u
n+1
j1
2u
n+1
j
+ u
n+1
j+1
. .
_
which might, at rst glance, look o-puttingly complicated. To aid clarity, certain groups of terms
have been gathered together in the above:
these are the terms that appeared on the right hand side of the explicit method and are involved
with approximating u
xx
at time t = n t
these are very similar to the terms, but all the superscripts are n+1 instead of n, that is the
terms approximate u
xx
at time t = (n + 1) t
(the factor of
1
2
outside the large bracket shows that we take the average of and )
Figure 7 shows another way of thinking of this numerical method. As in the earlier diagram of this
type, arrows point away from positions relating to terms on the right-hand side of the numerical
scheme.
j 1
j
j + 1
n
n + 1
Figure 7
The new terms in the Crank-Nicolson method, as compared with the explicit method, give rise to
two new unlled circles on the diagram and the horizontal arrows.
The implementation of this method is similar to that used for the explicit method, but there is a key
dierence. The Crank-Nicolson scheme is implicit, for consider its use in the rst time-step when
nding u
1
j
,
u
1
j
= u
0
j
..
+
1
2
r
_
u
0
j1
..
2 u
0
j
..
+u
0
j+1
..
+ u
1
j1
2u
1
j
+ u
1
j+1
. .
?
_
The terms labelled are known from the initial condition. But there are other unknown terms on
the right-hand side. We cannot simply read o the values at the new time-step as we did using the
explicit scheme. Instead we have to store all of the equations given by the stencil at a particular time-
step and then solve them as a system of simultaneous equations. The following Example illustrates
this point.
HELM (2005):
Section 32.4: Parabolic PDEs
59
www.ebookcraze.blogspot.com
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
Example 17
The temperature u(x, t) of a metal bar of length = 1.2 at a distance x from one
end and at time t is modelled by the partial dierential equation
u
t
= u
xx
(0 < x < , t > 0).
It is given that the metal has diusivity = 1, that the two ends of the bar are
kept at temperature u = 0 and that the initial temperature distribution is
u(x, 0) = f(x) = x
_
( x)
3
Use the Crank-Nicolson dierence scheme with x = 0.4 and t = 0.1 to approx-
imate u(x, t) at t = t and t = 2t.
Solution
In this case r = t/(x)
2
= 0.62500 so that the numerical scheme can be written
u
n+1
j
= u
n
j
+
0.62500
2
(u
n
j1
2u
n
j
+ u
n
j+1
+ u
n+1
j1
2u
n+1
j
+ u
n+1
j+1
)
Moving the unknowns to the left of the equation we obtain
0.31250u
n+1
j1
+ 1.62500u
n+1
j
0.31250u
n+1
j+1
= 0.37500u
n
j
+ 0.31250(u
n
j1
+ u
n
j+1
)
The rst stage is to use the given data to nd u
0
j
u
0
0
= 0 from the boundary condition
u
0
1
= f(x) = f(0.4) = 0.28622 from the initial condition
u
0
2
= f(2x) = f(0.8) = 0.20239 from the initial condition
u
0
3
= 0 from the boundary condition
The rst time-step will nd u
1
j
. First we note that the boundary condition implies that u
1
0
= u
1
3
= 0.
Two uses of the stencil give
0.31250u
1
0
+ 1.62500u
1
1
0.31250u
1
2
= 0.37500u
0
1
+ 0.31250(u
0
0
+ u
0
2
) = 0.17058
0.31250u
1
1
+ 1.62500u
1
2
0.31250u
1
3
= 0.37500u
0
2
+ 0.31250(u
0
1
+ u
0
3
) = 0.16534
The implicit nature of this method means that we have to do some extra work to complete the
time-step. We must now solve the simultaneous equations
_
1.62500 0.31250
0.31250 1.62500
__
u
1
1
u
1
2
_
=
_
0.17058
0.16534
_
In this case there are only two unknowns and it is a simple matter to solve the pair of equations to
give u
1
1
= 0.12932 and u
1
2
= 0.12662.
60 HELM (2005):
Workbook 32: Numerical Initial Value Problems
www.ebookcraze.blogspot.com
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
Solution (contd.)
The second time-step will nd u
2
j
. First we note that the boundary condition implies that u
2
0
=
u
2
3
= 0. Two uses of the stencil give
0.31250u
2
0
+ 1.62500u
2
1
0.31250u
2
2
= 0.37500u
1
1
+ 0.31250(u
1
0
+ u
1
2
) = 0.08806
0.31250u
2
1
+ 1.62500u
2
2
0.31250u
2
3
= 0.37500u
1
2
+ 0.31250(u
1
1
+ u
1
3
) = 0.08789
The implicit nature of this method means that we have to do some extra work to complete the
time-step. We must now solve the simultaneous equations
_
1.62500 0.31250
0.31250 1.62500
__
u
2
1
u
2
2
_
=
_
0.08806
0.08789
_
In this case there are only two unknowns and it is a simple matter to solve the pair of equations to
give u
2
1
= 0.06707 and u
2
2
= 0.06699.
Figure 8 depicts the numerical solutions found in Example 17 above. (Again, the dotted lines are
intended to aid clarity, they are not part of the numerical solution.)
u
0
j
u
1
j
u
2
j
x
u
0
0.05
0.1
0.15
0.2
0.25
0.3
0 0.4 0.8 1.2
Figure 8
HELM (2005):
Section 32.4: Parabolic PDEs
61
www.ebookcraze.blogspot.com
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
Task
The temperature u(x, t) of a metal bar of length = 0.9 at a distance x from one
end and at time t is modelled by the partial dierential equation
u
t
= u
xx
(0 < x < , t > 0).
It is given that the metal has diusivity = 0.25, that the two ends of the bar
are kept at temperature u = 0 and that the initial temperature distribution is
u(x, 0) = f(x) = sin(x/)
Use the Crank-Nicolson dierence scheme with x = 0.3 and t = 0.2 to approx-
imate u(x, t) at t = t and t = 2t.
Your solution
Initial condition and rst time-step:
62 HELM (2005):
Workbook 32: Numerical Initial Value Problems
www.ebookcraze.blogspot.com
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
Answer
In this case r = t/(x)
2
= 0.55556 so that the numerical scheme can be written
u
n+1
j
= u
n
j
+
0.55556
2
(u
n
j1
2u
n
j
+ u
n
j+1
+ u
n+1
j1
2u
n+1
j
+ u
n+1
j+1
)
Moving the unknowns to the left of the equation we obtain
0.27778u
n+1
j1
+ 1.55556u
n+1
j
0.27778u
n+1
j+1
= 0.44444u
n
j
+ 0.27778(u
n
j1
+ u
n
j+1
)
The rst stage is to use the given data to nd u
0
j
u
0
0
= 0 from the boundary condition
u
0
1
= f(x) = f(0.3) = 0.86603 from the initial condition
u
0
2
= f(2x) = f(0.6) = 0.86603 from the initial condition
u
0
3
= 0 from the boundary condition
The rst time-step will nd u
1
j
. First we note that the boundary condition implies that u
1
0
= u
1
3
= 0.
Two uses of the stencil give
0.27778u
1
0
+ 1.55556u
1
1
0.27778u
1
2
= 0.44444u
0
1
+ 0.27778(u
0
0
+ u
0
2
) = 0.62546
0.27778u
1
1
+ 1.55556u
1
2
0.27778u
1
3
= 0.44444u
0
2
+ 0.27778(u
0
1
+ u
0
3
) = 0.62546
The implicit nature of this method means that we have to do some extra work to complete the
time-step. We must now solve the simultaneous equations
_
1.55556 0.27778
0.27778 1.55556
__
u
1
1
u
1
2
_
=
_
0.62546
0.62546
_
In this case there are only two unknowns and it is a simple matter to solve the pair of equations to
give u
1
1
= 0.48949 and u
1
2
= 0.48949.
Your solution
Second time-step:
HELM (2005):
Section 32.4: Parabolic PDEs
63
www.ebookcraze.blogspot.com
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
Answer
The second time-step will nd u
2
j
. First we note that the boundary condition implies that u
2
0
=
u
2
3
= 0. Two uses of the stencil give
0.27778u
2
0
+ 1.55556u
2
1
0.27778u
2
2
= 0.44444u
1
1
+ 0.27778(u
1
0
+ u
1
2
) = 0.35352
0.27778u
2
1
+ 1.55556u
2
2
0.27778u
2
3
= 0.44444u
1
2
+ 0.27778(u
1
1
+ u
1
3
) = 0.35352
The implicit nature of this method means that we have to do some extra work to complete the
time-step. We must now solve the simultaneous equations
_
1.55556 0.27778
0.27778 1.55556
__
u
2
1
u
2
2
_
=
_
0.35352
0.35352
_
In this case there are only two unknowns and it is a simple matter to solve the pair of equations to
give u
2
1
= 0.27667 and u
2
2
= 0.27667.
In general
Having now seen some instances with a relatively large x, we now look at the general case where
the space step may be much smaller. In this case there will be a larger system of equations to solve
at each time-step than was the case above.
In general, the procedure of moving the unknowns to the left hand side of the equation leads to
r
2
u
n+1
j1
+ (1 + r)u
n+1
j
r
2
u
n+1
j+1
=
r
2
u
n
j1
+ (1 r)u
n
j
+
r
2
u
n
j+1
which we apply all the way along the x-axis. That is, we put j = 1, 2, 3, . . . , J 1 in the above
expression and hence derive a system of equations for all the u with superscript n + 1.
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
1 + r
r
2
0 . . . . . . 0
r
2
1 + r
r
2
0
r
2
1 + r
r
2
.
.
.
.
.
.
.
.
.
.
.
.
r
2
0 . . . . . . 0
r
2
1 + r
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
u
n+1
1
u
n+1
2
u
n+1
3
.
.
.
u
n+1
J1
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
=
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
r
2
u
n
0
+ (1 r)u
n
1
+
r
2
u
n
2
+
r
2
u
n+1
0
r
2
u
n
1
+ (1 r)u
n
2
+
r
2
u
n
3
r
2
u
n
2
+ (1 r)u
n
3
+
r
2
u
n
4
.
.
.
r
2
u
n
J2
+ (1 r)u
n
J1
+
r
2
u
n
J
+
r
2
u
n+1
J
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
The underlined terms on the right-hand side will be known from the boundary conditions. The doubly
underlined quantities are new at the current time-step and involve the only appearances of n + 1
on the right-hand side. All the other u approximations at time level n +1 are unknown at this stage
and appear on the left.
The matrix on the left-hand side of the system has the following properties
It is independent of nnn. In other words, the same matrix appears at each time-step. (We saw
this in the example and exercise above in which the same 2 2 matrix appeared at each of the
two time-steps carried out).
64 HELM (2005):
Workbook 32: Numerical Initial Value Problems
www.ebookcraze.blogspot.com
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
It is tridiagonal. That is, the only non-zero entries are either on, or adjacent to, the diagonal.
Furthermore, there are only two dierent values (
r
2
and 1 + r) which appear. This is good
news as far as storage is concerned. Gaussian elimination (seen in 30, for example) works
extremely well on tridiagonal matrices.
It is also true that the matrix is strictly diagonally dominant. (That is, the diagonal element on
each row is greater in size than the sum of the absolute values of the o-diagonal elements on that
row.) This means that methods such as Jacobi and Gauss Seidel (see 30 for details) would
work very well.
Stability of the Crank-Nicolson scheme
This is the big pay-o when using the Crank-Nicolson method.
Key Point 21
The Crank-Nicolson method is stable for all values of r.
This is excellent news. It means that there is no hideously restrictive constraint on the size of t.
7. Cost -v- benet
At a rst reading of this Section, it might be tempting to think that the extra eort involved in using
Crank-Nicolson (we have to store a set of simultaneous equations, we have to solve them and we
have to do this at every time-step) is enough to make the explicit method the winner in a cost-benet
analysis. But this would be wrong.
In practical problems involving numerical approximations to parabolic problems the explicit method
is rarely good enough. The stability constraint (r
1
2
) imposes such tiny time-steps that it takes
a great deal of time for a computer to produce approximations corresponding to even fairly modest
values of t. If eciency is what matters, then Crank-Nicolson beats the explicit approach, and it is
worth the extra initial eort formulating a solver (such as those we saw in 30) for the system
of equations.
HELM (2005):
Section 32.4: Parabolic PDEs
65
www.ebookcraze.blogspot.com
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
Exercises
1. Consider the function u dened by
u(x, t) = x
3
cos(xt)
Using increments of x = 0.005 and t = 0.01, and working to 8 decimal places, approximate
(a) u
x
(2, 3) with a one-sided forward dierence
(b) u
xx
(2, 3) with a central dierence
(c) u
t
(2, 3) with a one-sided forward dierence
(d) u
t
(2, 3) with a central dierence.
State the approximate derivatives to 3 decimal places.
2. The temperature u(x, t) of a metal bar of length = 3 at a distance x from one end and at
time t is modelled by the partial dierential equation
u
t
= u
xx
(0 < x < , t > 0)
It is given that the metal has diusivity = 1.6, that the two ends of the bar are kept at
temperature u = 0 and that the initial temperature distribution is
u(x, 0) = f(x) = x( x)
Use the explicit dierence scheme with x = 0.75 and t = 0.08 to approximate u(x, t) at
t = t and t = 2t.
3. The temperature u(x, t) of a metal bar of length = 1.2 at a distance x from one end and at
time t is modelled by the partial dierential equation
u
t
= u
xx
(0 < x < , t > 0).
It is given that the metal has diusivity = 2.25, that the two ends of the bar are kept at
temperature u = 0 and that the initial temperature distribution is
u(x, 0) = f(x) = sin(x/)
Use the Crank-Nicolson dierence scheme with x = 0.4 and t = 0.06 to approximate u(x, t)
at t = t and at t = 2t.
66 HELM (2005):
Workbook 32: Numerical Initial Value Problems
www.ebookcraze.blogspot.com
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
Answers
1. The evaluations of u we will need are u(x, t) = 0.41614684, u(x + x, t) = 0.43162908,
u(x x, t) = 0.40095819, u(x, t + t) = 0.42521885, u(x, t t) = 0.40703321. It
follows that
(a) u
x
(1, 2)
0.43162908 + 0.41614684
0.005
= 3.096
(b) u
xx
(1, 2)
0.43162908 + 2 0.41614684 0.40095819
0.005
2
= 11.744
(c) u
t
(1, 2)
0.42521885 + 0.41614684
0.01
= 0.907
(d) u
t
(1, 2)
0.42521885 + 0.40703321
2 0.01
= 0.909
to 3 decimal places. (Workings shown to 8 decimal places.)
2. In this case r =
2
t/(x)
2
= 0.227556 so that the numerical scheme can be written
u
n+1
j
= u
n
j
+ 0.227556(u
2
j1
2u
n
j
+ u
n
j+1
) = 0.544889u
n
j
+ 0.227556(u
2
j1
+ u
n
j+1
)
The rst stage is to use the given data to nd u
0
j
u
0
0
= 0 from the boundary condition
u
0
1
= f(x) = f(0.75) = 1.6875 from the initial condition
u
0
2
= f(2x) = f(1.5) = 2.25 from the initial condition
u
0
3
= f(3x) = f(2.25) = 1.6875 from the initial condition
u
0
4
= 0 from the boundary condition
The rst timestep will nd u
1
j
. We note that the boundary condition implies that u
1
0
= u
1
4
= 0.
u
1
1
=0.544889u
0
1
+ 0.227556(u
0
0
+ u
0
2
)=0.5448891.6875 + 0.227556(0 + 2.25) = 1.4315
u
1
2
=0.544889u
0
2
+ 0.227556(u
0
1
+ u
0
3
)=0.5448892.25 + 0.227556(1.688 + 1.688) = 1.994
u
1
3
=0.544889u
0
3
+ 0.227556(u
0
2
+ u
0
4
)=0.5448891.6875 + 0.227556(2.25 + 0) = 1.4315
The second timestep will nd u
2
j
. First we note that the boundary condition implies that
u
2
0
= u
2
4
= 0.
u
2
1
=0.544889u
1
1
+ 0.227556(u
1
0
+ u
1
2
)=0.5448891.4315 + 0.227556(0 + 1.994) = 1.233754
u
2
2
=0.544889u
1
2
+ 0.227556(u
1
1
+ u
1
3
)=0.5448891.994 + 0.227556(1.432 + 1.432) = 1.738
u
2
3
=0.544889u
1
3
+ 0.227556(u
1
2
+ u
1
4
)=0.5448891.4315 + 0.227556(1.994 + 0) = 1.233754
where some quantities have been rounded to 6 decimal places.
HELM (2005):
Section 32.4: Parabolic PDEs
67
www.ebookcraze.blogspot.com
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
w
w
w
.
e
b
o
o
k
c
r
a
z
e
.
b
l
o
g
s
p
o
t
.
c
o
m
Answers
3. In this case r = t/(x)
2
= 0.84375 so that the numerical scheme can be written
u
n+1
j
= u
n
j
+
0.84375
2
(u
n
j1
2u
n
j
+ u
n
j+1
+ u
n+1
j1
2u
n+1
j
+ u
n+1
j+1
)
Moving the unknowns to the left of the equation we obtain
0.42188u
n+1
j1
+ 1.84375u
n+1
j
0.42188u
n+1
j+1
= 0.15625u
n
j
+ 0.42188(u
n
j1
+ u
n
j+1
)
The rst stage is to use the given data to nd u
0
j
u
0
0
= 0 from the boundary condition
u
0
1
= f(x) = f(0.4) = 0.86603 from the initial condition
u
0
2
= f(2x) = f(0.8) = 0.86603 from the initial condition
u
0
3
= 0 from the boundary condition
The rst time-step will nd u
1
j
. First we note that the boundary condition implies that
u
1
0
= u
1
3
= 0. Two uses of the stencil give
0.42188u
1
0
+ 1.84375u
1
1
0.42188u
1
2
= 0.15625u
0
1
+ 0.42188(u
0
0
+ u
0
2
) = 0.50067
0.42188u
1
1
+ 1.84375u
1
2
0.42188u
1
3
= 0.15625u
0
2
+ 0.42188(u
0
1
+ u
0
3
) = 0.50067
The implicit nature of this method means that we have to do some extra work to complete
the time-step. We must now solve the simultaneous equations
_
1.84375 0.42188
0.42188 1.84375
__
u
1
1
u
1
2
_
=
_
0.50067
0.50067
_
In this case there are only two unknowns and it is a simple matter to solve the pair of equations
to give u
1
1
= 0.35212 and u
1
2
= 0.35212.
The second time-step will nd u
2
j
. First we note that the boundary condition implies that
u
2
0
= u
2
3
= 0. Two uses of the stencil give
0.42188u
2
0
+ 1.84375u
2
1
0.42188u
2
2
= 0.15625u
1
1
+ 0.42188(u
1
0
+ u
1
2
) = 0.20357
0.42188u
2
1
+ 1.84375u
2
2
0.42188u
2
3
= 0.15625u
1
2
+ 0.42188(u
1
1
+ u
1
3
) = 0.20357
The implicit nature of this method means that we have to do some extra work to complete
the time-step. We must now solve the simultaneous equations
_
1.84375 0.42188
0.42188 1.84375
__
u
2
1
u
2
2
_
=
_
0.20357
0.20357
_
In this case there are only two unknowns and it is a simple matter to solve the pair of equations
to give u
2
1
= 0.14317 and u
2
2
= 0.14317.
68 HELM (2005):
Workbook 32: Numerical Initial Value Problems
www.ebookcraze.blogspot.com