Finite Difference Method
Finite Difference Method
governs the flow of current in a vacuum tube with three internal elements. Let f..t = ~, yeO) =
0, and y(2) = 1. Approximate the solution yet) for t = 0.2i, where I < i ::5 9.
y" = p(x)y' + q(x)y + rex), a <X < b, yea) = a, y(b) = {3, (11.14)
requires that difference-quotient approximations be used to approximate both y' and y".
First, we select an integer N > 0 and divide the interval [a, b] into (N + 1) equal subin-
tervals whose endpoints are the mesh points Xi = a + ih, for i = 0, 1, ... , N + 1, where
h = (b - a)j(N + 1). Choosing the step size h in this manner facilitates the application
of a matrix algorithm from Chapter 6, which solves a linear system involving an N x N
matrix.
At the interior mesh points, Xi, for i = 1, 2, ... , N, the differential equation to be
approximated is
Expanding y in a third Taylor polynomial about Xi evaluated at Xi+1 and Xi-I, we have,
assuming that y E C 4 [Xi_l, xi+d,
for some ~i- in (Xi -I, Xi). If these equations are added, we have
(11.16)
for some ~i in (Xi-I, Xi+l)' This is called the centered-difference formula for y"(x;).
A centered-difference formula for y' (Xi) is obtained in a similar manner (the details
were considered in Section 4.1), resulting in
(11.17)
y(xi+d - Y(Xi-l)
2h
+ q (Xi )Y (Xi )
A Finite-Difference method with truncation error of order O(h2) results by using this
equation together with the boundary conditions yea) = a and y(b) = fJ to define
Wo = a,
and
and the resulting system of equations is expressed in the tridiagonal N x N matrix fOlIn
Aw = b, where (11.19)
662 C HAP T E R 11 • Boundary-Value Problems for Ordinary Differential Equations
h
2 + h 2q(XI) -1 + 2 P(XI) 0:::·························· 0
• •
h •
-1 - 2 P (X?! 2+ h 2q(X2) •
•
• • • •
A= o. •
•
• •
•
• • •
•
•
o ,
• •
•
•
• • •
• •
• .. h
•
•
•
• •
•
. . 2 P (XN I) -I +
• •
· • . . '. h'· . . . ,
0························ ::·0 -I - 2 P (XN) . 2+h-q(XN)
h
I+ P(XI) Wo
2
w= •
•
•
, and b=
•
•
The following theorem gives conditions under which the tridiagonal linear system
(11.19) has a unique solution. Its proof is a consequence of Theorem 6.29 and is considered
in Exercise 9.
Theorem 11.3 Suppose that p, q, and r are continuous on [a, b]. If q(x) > 0 on [a, b], then the tridi-
agonal linear system (1l.19) has a unique solution provided that h < 2jL, where L
maxa<x:cb Ip(x)l· •
•
It should be noted that the hypotheses of Theorem 11.3 guarantee a unique solution to
the boundary-value problem (11.14), but they do not guarantee that y E C 4 [a, b J. We need
to establish that l4) is continuous on [a, b J to ensure that the truncation error has order
O(h2).
Algorithm 11.3 implements the Linear Finite-Difference method.
Linear Finite-Difference
To approximate the solution of the boundary-value problem
Step 3 Set x = b - h;
aN = 2 + h2q(x);
CN = -1 - (h/2)p(x);
d N = -h 2 r(x) + (1 - (h/2)p(x»f3.
Step 4 Set 11 = a1; (Steps 4-8 solve a tridiagonal linear system using Algorithm 6.7.)
UI = bl/a];
;:1 = d l / I].
of Y(Xi+l) and Y(Xi-l), but also of Y(Xi+2) and Y(Xi-2) in the approximation forlIlulas for
y" (Xi) and y' (Xi)' This leads to difficulty at i = a and i = N. Moreover, the resulting
system of equations analogous to (11.1 9) is not in tridiagonal fonn, and the solution to the
system requires many more calculations.
Instead of attempting to obtain a difference method with a higher-order truncation
error in this manner, it is generally more satisfactory to consider a reduction in step size.
In addition, Richardson's extrapolation technique can be used effectively for this method
since the error tenn is expressed in even powers of h with coefficients independent of h,
provided Y is sufficiently differentiable (see, for example, [Keller, H, p. 81]).
2 I 2 sin(lnx)
y" = - - y
X
+ x2
- y + ---;:---'-
x2'
1 .::: X .::: 2, y(l) = 1, y(2) = 2,
with h = O. I, 0.05, and 0.025, gives the results listed in Table 1 1.4. The first extrapolation
•
IS
ntble 11A
Xj wj(h = 0.1) wj(h = 0.05) Wj (h = 0.025) ExtJj Ext2j Ext3j
16Ext2i - Extli
Ext3' =
I
---=---::...
15
All the results of EXt3i are correct to the decimal places listed. In fact, if sufficient dig-
its had been used, this approximation would agree with the exact solution with maximum
error of 6.3 x 10- 11 at the mesh points, an impressive improvement. -
has the solution y(x) = - l~ (sin x + 3 cos x). Use the Linear Finite-Difference Algorithm to
approximate the solution, and compare the results to the actual solution.
a. With h = ~; b. With h = ~.
c. Use extrapolation to approximate y(rr /4).
3. Use the Linear Finite-Difference Algorithm to approximate the solution to the following
boundary-value problems.
a. y" = -3y' + 2y + 2x + 3, 0 <x < I, yeO) = 2, y(l) = I; use h = 0.1.
b. y" = -:y' +!ry - ~ lnx, 1:5 x <2, y(l) = -i, y(2) = In2; use h = 0.05.
c. y" = -(x + I)y' + 2y + (l - x 2 )e- x , 0:5 x < I, yeO) = -I, y(l) = 0; use h = 0.1.
d. y" = f + .!rY + ~x - I, 1:5 x :5 2, y(l) = y(2) = 0; use h = 0.1.
4. Although q (x) < 0 in the following boundary-value problems, unique solutions exist and are
given. Use the Linear Finite-Difference Algorithm to approximate the solutions, and compare
the results to the actual solutions.
a. y" + Y = 0, 0 < x < ~,y(O) = I, y(~) = 1; use h = :0; actual solution y(x) =
cos x + (.J2 - 1) sinx.
666 C HAP T E R 11 • Boundary-Value Problemsfor Ordinary Differential Equations
d1w S qx
dx 2 = EI W + 2EI (x -1), 0 < x < 1,
S -ql q
W"(x) - D W(x) = 2D x + 2D x2 , 0 <x < I, W(O) = W(l) = 0,
where I is the length of the plate and D is the flexual rigidity of the plate. Let q = 200
Ib/in. z, S = 100 Ib/in., D = 8.8 X 107 lb/in., and I = 50 in. Approximate the deflection at
I-in. intervals.
9. Prove Theorem 11.3. [Hint: To use Theorem 6.29, first show that ; P(Xi) < 1 implies that I
1-1 - ;P(Xi)! + I-I
+ ;p(xi)1 = 2.]
10. Show that if y E C 6 [a, b) and if wo, WI, ... , WN+I satisfy Eq. (11.18), then
the difference method is similar to the method applied to linear problems in Section 11.3.
Here, however, the system of equations will not be linear, so an iterative process is required
to solve it.
For the development of the procedure, we assume throughout that f satisfies the fol-
lowing conditions:
D = {(x, y, y') Ia <x < b, -00 < y < 00, -00 < y' < oo};
by the appropriate centered-difference fOImula given in Eqs. (11.16) and (11.17). This
gives, for each i = 1, 2, . .. , N,
2
y(xi+d -: 2Y(Xi) + y(xi-d = f y(xi+d - Y(Xi-I) h '"
h2
Xi, y(Xj), 2h -6 Y (1]i)
•
Wo = a, WN+l = fl,
and
Xi, Wi, = 0,
2h
= 0,
2h
2 f3 - WN-I
-WN-I+2wN+hf XN,WN, 2h -f3=0
generated that converges to the solution of system (11.20), provided that the initial appro x -
. .
ImatlOn (wI . suffi'
0 ) ' w (0) , ... , w (0))' IS clen tIy c Iose to the soIutlon
' ( WI, W2, ... , WN )' , and
2 N
that the Jacobian matrix for the system is nonsingular. For system (11.20), the Jacobian
matrix J(WI, ... , WN) is tridiagonal with ij-th entry
h Wi+1 - Wi-I
-1 + 2 fyl Xi, Wi,
2h
, for i = j - 1 and j = 2, . .. ,N,
2 Wi+! - Wi-!
2 +h fy Xi, Wi, 2h , for i = j and j = 1, ... , N,
h Wi+l - Wi-l
2 y / x'I ,
-1--/ W,I , 2h , for i = j + 1 and j = 1, . .. , N - 1,
- WI + 2W2 - W3 +h f2
Xz, W2,
2h
, .. . ,
,
2h
,
-f3
Since J is tridiagonal, this is not as fonnidable a problem as it might at first appear. The
Crout Factorization Algorithm (6.7) can be applied. The process is detailed in Algorithm
11.4.
Nonlinear Finite-Difference
To approximate the solution to the nonlinear boundary-value problem
EXAMPLE 1 We apply Algorithm 11.4, with h = 0.1, to the nonlinear boundary-value problem
1 3 43
y" = 8 (32 + 2x - yy'), 1 :::: x :::: 3, y(1) = 17, y(3) = 3'
giving the results in Table 11.5. The stopping procedure used in this example was to iterate
until values of successive iterates differed by less than 10- 8 . This was accomplished with
four iterations. The problem in this example is the same as that considered for the Nonlinear
Shooting method, Example 1 of Section 11.2. •
Richardson's extrapolation procedure can also be used for the Nonlinear Finite-
Difference method. Table 11.6 lists the results when this method is applied to our example
using h = 0.1,0.05, and 0.025, with four iterations in each case. The notation is the same
as in Example 2 of Section 11.3, and the values of Ext3i are all accurate to the places listed,
with an actual maximum error of 3.68 x 10- 10 . The values of wi(h = 0.1) are omitted
from the table, since they were listed previously.