404 Chapter 7 Numerical Methods
The spatial derivatives in a heat problem will be replaced by difference quo-
tients, as before:
∂^2 u
∂x^2 (xi,tm)→
ui+ 1 (m)− 2 ui(m)+ui− 1 (m)
( x)^2 , (1)
∂u
∂x(xi,tm)→
ui+ 1 (m)−ui− 1 (m)
2 x. (2)
For the time derivative, there are several possible replacements. We limit our-
selves to the forward difference
∂u
∂t(xi,tm)→
ui(m+ 1 )−ui(m)
t , (3)
which will yield explicit formulas for computing.
Now, to solve numerically the simple heat problem
∂^2 u
∂x^2 =
∂u
∂t,^0 <x<^1 ,^0 <t, (4)
u( 0 ,t)= 0 , u( 1 ,t)= 0 , 0 <t, (5)
u(x, 0 )=f(x), 0 <x< 1 , (6)
we set up replacement equations according to Eqs. (1)–(3). Those equations
are
ui− 1 (m)− 2 ui(m)+ui+ 1 (m)
( x)^2 =
ui(m+ 1 )−ui(m)
t , (7)
supposed valid fori= 1 , 2 ,...,n−1andm= 0 , 1 , 2 ,....
The point of using a forward difference for the time derivative is that these
equations may be solved forui(m+ 1 ):
ui(m+ 1 )=rui− 1 (m)+( 1 − 2 r)ui(m)+rui+ 1 (m), (8)
wherer= t/( x)^2 .Thuseachui(m+ 1 )is calculated fromu’s at the preced-
ing time level. Because the initial condition gives eachui( 0 ),thevaluesofthe
u’s at time level 1 can be calculated by settingm=0 in Eq. (8):
ui( 1 )=rui− 1 ( 0 )+( 1 − 2 r)ui( 0 )+rui+ 1 ( 0 ).
Then the values of theu’s at time level 2 can be found from these, and so on
into the future. Of course,rhas to be given a numerical value first, by choosing
xand t.
It is convenient to display the numerical values ofui(m)in a table, making
columns correspond to different meshpointsx 0 ,x 1 ,...,xnand making rows
correspond to the different time levelst 0 ,t 1 ,....SeeTable4.