6.5 Second-Order Boundary-Value Problems
INTRODUCTION
We just saw in Section 6.4 how to approximate the solution of a second-order initial-value problem y″ = f(x, y, y′), y(x0) = y0, y′(x0) = u0. In this section we are going to examine two methods for approximating a solution of a second-order boundary-value problem y″ = f(x, y, y′), y(a) = α, y(b) = β. Unlike the procedures used with second-order initial-value problems, the methods of second-order boundary-value problems do not require rewriting the second-order DE as a system of first-order DEs.
Finite Difference Approximations
The Taylor series expansion, centered at a point a, of a function y(x) is
If we set h = x − a, then the preceding line is the same as
For the subsequent discussion it is convenient, then, to rewrite this last expression in two alternative forms:
(1)
and (2)
If h is small, we can ignore terms involving h4, h5, . . . , since these values are negligible. Indeed, if we ignore all terms involving h2 and higher, then solving (1) and (2), in turn, for y′(x) yields the following approximations for the first derivative:
(3)
(4)
Subtracting (1) and (2) also gives
(5)
On the other hand, if we ignore terms involving h3 and higher, then by adding (1) and (2) we obtain an approximation for the second derivative y″(x):
(6)
The right sides of (3), (4), (5), and (6) are called difference quotients. The expressions
y(x + h) − y(x), y(x) − y(x − h), y(x + h) − y(x − h)
and y(x + h) − 2y(x) + y(x − h)
are called finite differences. Specifically, y(x + h) − y(x) is called a forward difference, y(x) − y(x − h) is a backward difference, and both y(x + h) − y(x − h) and y(x + h) − 2y(x) + y(x − h) are called central differences. The results given in (5) and (6) are referred to as central difference approximations for the derivatives y′ and y″.
Finite Difference Method
Consider now a linear second-order boundary-value problem
(7)
Suppose a = x0 < x1 < x2 < . . . < xn– 1 < xn = b represents a regular partition of the interval [a, b]; that is, xi = a + ih, where i = 0, 1, 2, . . . , n and h = (b − a)/n. The points
x1 = a + h, x2 = a + 2h, . . ., xn– 1 = a + (n − 1)h,
are called interior mesh points of the interval [a, b]. If we let
yi = y(xi), Pi = P(xi), Qi = Q(xi), and fi = f(xi)
and if y″ and y′ in (7) are replaced by the central difference approximations (5) and (6), we get
or, after simplifying,
(8)
The last equation, known as a finite difference equation, is an approximation to the differential equation. It enables us to approximate the solution y(x) of (7) at the interior mesh points x1, x2, . . . , xn – 1 of the interval [a, b]. By letting i take on the values 1, 2, . . . , n − 1 in (8), we obtain n − 1 equations in the n − 1 unknowns y1, y2, . . . , yn−1. Bear in mind that we know y0 and yn, since these are the prescribed boundary conditions y0 = y(x0) = y(a) = α and yn = y(xn) = y(b) = β.
In Example 1 we consider a boundary-value problem for which we can compare the approximate values found with the exact values of an explicit solution.
EXAMPLE 1 Using the Finite Difference Method
Use the difference equation (8) with n = 4 to approximate the solution of the boundary-value problem
y″ − 4y = 0, y(0) = 0, y(1) = 5.
SOLUTION
To use (8) we identify P(x) = 0, Q(x) = −4, f(x) = 0, and h = (1 − 0)/4 = . Hence the difference equation is
yi + 1 − 2.25yi + yi – 1 = 0.(9)
Now the interior points are x1 = 0 + , x2 = 0 + , x3 = 0 + , and so for i = 1, 2, and 3, (9) yields the following system for the corresponding y1, y2, and y3:
y2 − 2.25y1 + y0 = 0
y3 − 2.25y2 + y1 = 0
y4 − 2.25y3 + y2 = 0.
With the boundary conditions y0 = 0 and y4 = 5, the foregoing system becomes
Solving the system gives y1 = 0.7256, y2 = 1.6327, and y3 = 2.9479.
Now the general solution of the given differential equation is y = c1 cosh 2x + c2 sinh 2x. The condition y(0) = 0 implies c1 = 0. The other boundary condition gives c2. In this way we see that an explicit solution of the boundary-value problem is
Thus the exact values (rounded to four decimal places) of this solution at the interior points are as follows: y(0.25) = 0.7184, y(0.5) = 1.6201, and y(0.75) = 2.9354. ≡
The accuracy of the approximations in Example 1 can be improved by using a smaller value of h. Of course, the trade-off here is that a smaller value of h necessitates solving a larger system of equations. It is left as an exercise to show that with h = , approximations to y(0.25), y(0.5), and y(0.75) are 0.7202, 1.6233, and 2.9386, respectively. See Problem 11 in Exercises 6.5.
EXAMPLE 2 Using the Finite Difference Method
Use the difference equation (8) with n = 10 to approximate the solution of
y″ + 3y′ + 2y = 4x2, y(1) = 1, y(2) = 6.
SOLUTION
In this case we identify P(x) = 3, Q(x) = 2, f(x) = 4x2, and h = (2 − 1)/10 = 0.1, and so (8) becomes
(10)
Now the interior points are x1 = 1.1, x2 = 1.2, x3 = 1.3, x4 = 1.4, x5 = 1.5, x6 = 1.6, x7 = 1.7, x8 = 1.8, and x9 = 1.9. For i = 1, 2, . . . , 9 and y0 = 1, y10 = 6, (10) gives a system of nine equations and nine unknowns:
We can solve this large system using Gaussian elimination or, with relative ease, by means of a computer algebra system. The result is found to be y1 = 2.4047, y2 = 3.4432, y3 = 4.2010, y4 = 4.7469, y5 = 5.1359, y6 = 5.4124, y7 = 5.6117, y8 = 5.7620, and y9 = 5.8855. ≡
Shooting Method
Another way of approximating a solution of a second-order boundary-value problem y″ = f(x, y, y′), y(a) = α, y(b) = β, is called the shooting method. The starting point in this method is the replacement of the boundary-value problem by an initial-value problem
y″ = f(x, y, y′), y(a) = α, y′(a) = m1.(11)
The number m1 in (11) is simply a guess for the unknown slope of the solution curve at the known point (a, y(a)). We then apply one of the step-by-step numerical techniques to the second-order equation in (11) to find an approximation β1 for the value of y(b). If β1 agrees with the given value y(b) = β to some preassigned tolerance, we stop; otherwise the calculations are repeated, starting with a different guess y′(a) = m2 to obtain a second approximation β2 for y(b). This method can be continued in a trial-and-error manner or the subsequent slopes m3, m4, . . . , can be adjusted in some systematic way; linear interpolation is particularly successful when the differential equation in (11) is linear. The procedure is analogous to shooting (the “aim” is the choice of the initial slope) at a target until the bullseye y(b) is hit. See Problem 14 in Exercises 6.5.
Of course, underlying the use of these numerical methods is the assumption, which we know is not always warranted, that a solution of the boundary-value problem exists.
REMARKS
The approximation method using finite differences can be extended to boundary-value problems in which the first derivative is specified at a boundary—for example, a problem such as y″ = f(x, y, y′), y′(a) = α, y(b) = β. See Problem 13 in Exercises 6.5.
6.5 Exercises Answers to selected odd-numbered problems begin on page ANS-15.
In Problems 1–10, use the finite difference method and the indicated value of n to approximate the solution of the given boundary-value problem.
- y″ + 9y = 0, y(0) = 4, y(2) = 1; n = 4
- y″ − y = x2, y(0) = 0, y(1) = 0; n = 4
- y″ + 2y′ + y = 5x, y(0) = 0, y(1) = 0; n = 5
- y″ − 10y′ + 25y = 1, y(0) = 1, y(1) = 0; n = 5
- y″ − 4y′ + 4y = (x + 1)e2x, y(0) = 3, y(1) = 0; n = 6
- y″ + 5y′ = 4, y(1) = 1, y(2) = –1; n = 6
- x2y″ + 3xy′ + 3y = 0, y(1) = 5, y(2) = 0; n = 8
- x2y″ − xy′ + y = ln x, y(1) = 0, y(2) = –2; n = 8
- y″ + (1 − x)y′ + xy = x, y(0) = 0, y(1) = 2; n = 10
- y″ + xy′ + y = x, y(0) = 1, y(1) = 0; n = 10
- Rework Example 1 using n = 8.
- The electrostatic potential u between two concentric spheres of radius r = 1 and r = 4 is determined from
Use the method of this section with n = 6 to approximate the solution of this boundary-value problem.
- Consider the boundary-value problem
y″ + xy = 0, y′(0) = 1, y(1) = −1.
- Find the difference equation corresponding to the differential equation. Show that for i = 0, 1, 2, . . . , n − 1, the difference equation yields n equations in n + 1 unknowns y–1, y0, y1, y2, . . . , yn – 1. Here y–1 and y0 are unknowns since y–1 represents an approximation to y at the exterior point x = –h and y0 is not specified at x = 0.
- Use the central difference approximation (5) to show that y1 − y–1 = 2h. Use this equation to eliminate y–1 from the system in part (a).
- Use n = 5 and the system of equations found in parts (a) and (b) to approximate the solution of the original boundary-value problem.
Computer Lab Assignment
- Consider the boundary-value problem y″ = y′ − sin(xy), y(0) = 1, y(1) = 1.5. Use the shooting method to approximate the solution of this problem. (The actual approximation can be obtained using a numerical technique, say, the fourth-order Runge–Kutta method with h = 0.1; even better, if you have access to a CAS, such as Mathematica or Maple, the NDSolve function can be used.)