NUMERICAL SOLUTION OF SECOND-ORDER ORDINARY DIFFERENTIAL EQUATIONS 59
The coefficient matrix on the left-hand side of (2.2.13) is called a tridiagonal
matrix, whose nonvanishing elements form a band, three elements wide along
the diagonal. This particular set of equations can be solved by using the Gaussian
elimination method. According to this method, we multiply the second equation
in (2.2.13) by C
12
and the first by C
21
and then take the difference of the two to
eliminate f
1
. The resulting equation is
(C
22
C
12
−C
21
C
13
) f
2
+C
23
C
12
f
3
= C
24
C
12
−C
21
C
14
In this equation, if we call the coefficient of f
2
by the name C
22
,thatoff
3
by the
name C
23
, and the group on the right-hand side by the name C
24
, and if the final
equation is used to replace the second equation in (2.2.13), the form of (2.2.13)
will remain unchanged except that C
21
is replaced by zero. Working with the new
second equation and the third equation in (2.2.13), C
31
can be eliminated by using
the same technique. The same process is repeated until C
n−1,1
is eliminated. In
summary, the eliminating processes are achieved by successively renaming the
coefficients according to the following assignments:
C
i2
← (C
i2
C
i−1,2
−C
i1
C
i−1,3
)
C
i3
← C
i3
C
i−1,2
C
i4
← (C
i4
C
i−1,2
−C
i1
C
i−1,4
)
⎫
⎬
⎭
i = 2, 3, ..., n − 1 (2.2.14)
At this stage, all the equations in (2.2.13) are in the simple form of having
only two terms on the left-hand side. The value of f
n
can immediately be found
by solving simultaneously the last two equations in (2.2.13). Thus,
f
n
=
C
n4
C
n−1,2
−C
n1
C
n−1,4
C
n2
C
n−1,2
−C
n1
C
n−1,3
(2.2.15)
It can easily be verified that the remaining unknowns can be calculated, in a
backward order, from the recurrence formula
f
j
=
C
j4
−C
j3
f
j+1
C
j2
, j = n −1, n −2, ...,2,1 (2.2.16)
The numerical method just described is now summarized as follows. The dif-
ferential equation (2.2.1) is first replaced by a set of difference equations (2.2.10),
whose coefficients are calculated according to (2.2.11). Boundary conditions are
taken care of by executing the actions shown in (2.2.12). Finally, the unknowns
f
i
, with i = 1, 2, ..., n, are computed by following the procedure represented by
(2.2.14) to (2.2.16). The last part of the computation will be programmed under
a subroutine named
TRID, which will appear in the next program.
Later in Chapter 4, we introduce other efficient methods for solving tridiag-
onal equations, i.e., the compact-storage Thomas algorithm based on Gaussian
elimination, and the LU decomposition, which is especially useful when many
systems have to be solved with the same coefficient matrix but with different
right-hand-sides, such as in parabolic partial differential equations with constant
coefficients.