0% found this document useful (0 votes)
8 views

Linear and Nonlinear Shooting Method

Uploaded by

sasafafs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Linear and Nonlinear Shooting Method

Uploaded by

sasafafs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

Boun -Va ue


Pro ems or Or Ina

I erentia uations
• • •

A common problem in civil engineering concerns the detlection of a


beam of rectangular cross section subject to uniform loading while the
ends of the beam are supported so that they undergo no deflection.

r--..... ,/

S S
f;::.
I x
0
w(x)

The differential equation approximating the physical situation is of


the form

tfw S qx .
dx 2 (x) = Elw(x) + 2E/x - f),

where w(x) is the deflection a distance x from the left end of the beam,
and l, q, E, S, and I represent, respectively, the length of the beam, the
intensity of the uniform load, the modulus of elasticity, the stress at the
endpoints, and the central moment of inertia. Since no detlection occurs
at the ends of the beam, we also have the two boundary conditions

w(O) = w(l) = O.
646 C HAP T E R 11 • Boundary-Value Problems jor Ordinary Differential Equations

When the beam is of uniform thickness, the product EI is constant,


and the exact solution is easily obtained. When the thickness is not uni-
form, the moment of inertia I is a function of x, and approximation tech-
niques are required. Problems of this type are considered in Exercises 7
of Section 11.3 and 6 of Section 11.4.

The differential equations in Chapter 5 are of first order and have one initial condi-
tion to satisfy. Later in the chapter we saw that the techniques could be extended to sys-
tems of equations and then to higher-order equations, but all the specified conditions are
on the same endpoint. These are initial-value problems. In this chapter we show how to
approximate the solution to boundary-value problems, differential equations with condi-
tions imposed at different points. For first-order differential equations, only one condition
is specified, so there is no distinction between initial-value and boundary-value.problems.
We will be considering second-order equations with two boundary values.
Physical problems that are position-dependent rather than time-dependent are often
described in telms of differential equations with conditions imposed at more than one point.
The two-point boundary-value problems in this chapter involve a second-order differential
equation of the form

y" = f(x, y, y'), a <x:::: b, (11.1)

together with the boundary conditions

yea) = a and y(b) = /3. (11.2)

11.1 The Linear Shooting Method


The following theorem gives general conditions that ensure that the solution to a second-
order boundary value problem exists and is unique. The proof of this theorem can be found
in [Keller, H].

Theorem 11.7 Suppose the function f in the boundary-value problem

y" = f(x, y, y'), a <x < b, yea) = a, y(b) = {3,


is continuous on the set

D = {(x, y, y') I a <x < b, -00 < y < 00, -00 < y' < oo},

and that the partial derivatives fy and f y' are also continuous on D. If
(i) fy (x, y, y') > 0, for all (x, y, y') E D, and
(ii) a constant M exists, with

h(x,y,y') < M, for all (x,y,y') E D,

then the boundary-value problem has a unique solution.



11.1 The Linear Shooting Method 647

EXAMPLE 1 The boundary-value problem

y" + e- xy + siny' = 0, I <x < 2, y(1) = y(2) = 0,


has

f(x, y, y') = _e- XY - siny'.

Since

fy(x, y, y') = xe- XY > 0 and fy'(X, y, y') = 1 - cos y'l < 1.

this problem has a unique solution. •


When f(x, y, y') has the form

f(x, y, y') = p(x)y' + q(x)y + rex),


the differential equation

y" = f (x, y, y')

is linear. Problems of this type frequently occur, and in this situation, Theorem 11.1 can
be simplified.

Corollary 11.2 If the linear boundary-value problem

y" = p(x)y' + q(x)y + rex), a < x <b, yea) = a, y(b) = (3,

satisfies
(i) p(x), q(x), and rex) are continuous on [a, b],
(ii) q(x) > 0 on [a, b],

then the problem has a unique solution.



To approximate the unique solution guaranteed by the satisfaction of the hypotheses
of Corollary 11.2, let us first consider the initial-value problems

y" = p(x)y' + q(x)y + rex), a <x < b, yea) = a, y'(a) = 0, (11.3)

and

y" = p(x)y' + q(x)y, a <x < b, yea) = 0, y'(a) = 1. (11.4)

Theorem 5.16 in Section 5.9 ensures that under the hypotheses in Corollary 11.2, both
problems have a unique solution. Let Yl (x) denote the solution to (11.3), Y2 (x) denote the
solution to (11.4), and let

(11.5)
648 C HAP T E R 11 • Boundary-Value Problems for Ordinary Differential Equations

Then

'() '() fJ-YI(b) I )


Y X = YI X + Y2(X
Y2(b)
and

"( ) _ I/()
Y X - YI X
+ fJ - YI (b) !/( )
Yo x .
Y2(b) ~

So

fJ - YI (b) ( ( ) I
1/ (
Y =p X YI +q
) I ()
X YI +r(x
)
+ yz(b) px h+q(X)Y2
)

I fJ-YI(b) I fJ - YI (b)
= P (X) YI + Y2(b) Y2 + q(x) YI + Y2(b) Y2 + rex)

= p(X)y'(X) + q(x)y(x) + rex).


Moreover,
fJ - YI(b) fJ - YI(b)
yea) = YI (a) + Y2(a) =a + ·0 =a
Y2(b) Y2(b)
and
fJ-YI(b)
y(b) = YI(b) + Y2(b) Y2(b) = YI(b) + fJ - YI(b) = {3.

Hence, y(x) is the unique solution to the linear boundary-value problem, provided, of
course, that Y2 (b) "I O. (That Y2 (b) = 0 is in conflict with the hypotheses of Corollary 11.2
is considered in Exercise 8.)
The Shooting method for linear equations is based on the replacement of the linear
boundary-value problem by the two initial-value problems (11.3) and (11.4). Numerous
methods are available from Chapter 5 for approximating the solutions YI (x) and Y2 (x),
and once these approximations are available, the solution to the boundary-value problem
is approximated using Eq. (11.5). Graphically, the method has the appearance shown in
Figure 11.1.

Figure 11.1
Y

f3
f3 - y](b)
y(x) = Yl(X) + yz(b) Yz(x)

Yl(X)

a b x
11.1 The Linear Shooting Method 649

Algorithm 11.1 uses the fourth-order Runge-Kutta technique to find the approxima-
tions to YI (x) and Y2(X), but another technique for approximating the solutions to initial-
value problems can be substituted into Step 4.
The algorithm has the additional feature of obtaining approximations for the derivative
of the solution to the boundary-value problem as well as to the solution of the problem
itself. The use of the algorithm is not restricted to those problems for which the hypotheses
of Corollary 11.2 can be verified; it will work for many problems that do not satisfy these
hypotheses.

Linear Shooting
To approximate the solution of the boundary-value problem

-y" + p(x)y' + q(x)y + rex) = 0, a < x <b, yea) = ex, y(b) = {3 :

(Note: Equations (11.3) and 01.4) are written as first-order systems and solved.)
INPUT endpoints a, b; boundary conditions ex, (3; number of subintervals N.
OUTPUT approximations w].i to y(Xi); W2.i to y'(Xi) for each i = 0, I, .. , , N.

Step 7 Seth=(b-a)/N;
UIO=ex;
,
U2,O = 0;
Vl,O = 0;
V2,O = 1.
Step 2 For i = 0, ... , N - 1 do Steps 3 and 4.
(The Runge-Kutta methodfor systems is used in Steps 3 and 4.)
Step 3 Set x = a + ih.
Step 4 Set kl , 1 = hU2 , i;
k1,2 = h [p(x )U2,i + q (x )ul,i + r(x)];
k 2,1 = h [U2,i + ~k1,2];
k2,2 = h [p(x + h/2) (U2,i + ~kl,2)
+q(x + h/2) (U].i + ~kl,l) + rex + h/2)];
k 3,1 = h [U2,i + ~k2,2];
k 3 ,2 = h [p(x+ h/2) (U2,i + ~k2,2)
+q(x + h/2)(u].i + ~k2,1) + rex + h/2)];
+ k 3 ,2];
k 4 ,1 = h [U2,i
k4 ,2 = h [p(x + h)(U2,i + k 3 ,2) + q(x + h)(ul,i + k 3 ,1) + rex + h)];
Ul,i+l = UI,i + ~ [kl,l + 2k2,1 + 2k3 ,1 + k4 ,1];

U2,i+! = U2,i + ~ [k 1,2 + 2k 2,2 + 2k 3 ,2 + k4 ,2];


ki,l = hV2,i;
650 C HAP T E R 11 • Boundary-value Problems for ordinary Differential Equations

k;,2 = h [p(X)V2,i + q(X)Vl,i];


k~, 1 = h [V2,i + ~ k; ,2];
k;,2 = h [p(X + h/2) (V2,i + ik;,2) + q(X + h/2) (Vl,i + ~k;,I)];
k~, I = h [V2,i + ; k;,2];
k~,2 = h [p(X + h/2) (V2,i + ik;,2) + q(X + h/2) (Vl,i + ~k~,I)];
k~, 1 = h [V2,; + k~,2];
k~,2 = h [p(X + h)(V2,i + k~,2) + q(X + h)(Vl,i + k~,I)];
Vl,i+1 = Vl,i +~ [k;,1 + 2k;,1 +2k~,1 +k~,I];
V2,i+1 = V2,i +~ [k;,2 + 2k;,2 + 2k~,2 + k~,2].
Step 5 Set WI , 0 = a;
{J-UI,N,
W2,O = ,
Vl,N
OUTPUT (a, WIO, W2,O),
Step 6 For i = 1, ' , . , N
set WI = Ul,i + W2,OV1,i;
W2 = U2,i + W2,OV2,i;
x=a+ih;
OUTPUT (x, WI, W2). (Output is Xi, Wl,i, W2,i.)
Step 7 STOP. (The process is complete.) •
EXAMPLE 2 The boundary-value problem

2 /
/I 2 sin(lnx)
y = --y + -2y + --::-- 1< X < 2, y(1) = 1, y(2) = 2,
X x x2 '

has the exact solution


C2 3 1
Y = CIX + -2 -
x
10 sin(lnx) - 10 cos(lnx),
where
1
C2 = [8 - 12 sin(ln 2) - 4cos(ln 2)] ~ -0.03920701320
70
and
11
CI = 10 - C2 ~ 1.1392070132. >
>
--
Applying Algorithm 11.1 to this problem requires approximating the solutions to the -•
initial-value problems •
,
,
2 / 2 sin (In x)
/I
YI = --Y
X 1
+ -Yl
x2 + ---;:--
x2'
1 < x < 2, Y; (1) = 0,
[
,
11.1 The Linear Shooting Method 651

and
2, 2 0
Y2
/I
= --Y2 + -Y2,
x X2
1 <x ~ 2, Y2(l) = , 1
Y2(l) = 1.
The results of the calculations, using Algorithm 11.1 with N = 10 and h = 0.1, are
given in Table 11.1. The value listed as U l.i approximates YI (Xi), the value vl,i approxi-
mates Y2 (Xi), and Wi approximates


Table 11.1 x, ,
U I,. ,
VI , . Wi y(x;) Iy(x;) - wd
1.0 1.00000000 0.00000000 1.00000000 1.00000000
1.1 1.00896058 0.09117986 1.09262917 1.09262930 1.43 x 10-7
1.2 1.03245472 0.16851175 1.18708471 1.18708484 1.34 x 10- 7
1.3 1.06674375 0.23608704 1.28338227 1.28338236 9.78 x 10- 8
1.4 1.10928795 0.29659067 1.38144589 1.38144595 6.02 x 10- 8
1.5 1.15830000 0.35184379 1.48115939 1.48115942 3.06 x 10- 8
1.6 1.21248372 0.40311695 1.58239245 1.58239246 1.08 x 10- 8
1.7 1.27087454 0.45131840 1.68501396 1.68501396 5.43 x lO- JO
1.8 1.33273851 0.49711137 1.78889854 1.78889853 5.05 x 10- 9
1.9 1.39750618 0.54098928 1.89392951 1.89392951 4.41 x 10- 9
2.0 1.46472815 0.58332538 2.00000000 2.00000000

The accurate results in this example are due to the fact that the fourth-order Runge-
Kutta method gives O(h4) approximations to the solutions of the initial-value problems.
Unfortunately, because of roundoff errors, there can be problems hidden in this technique.
If ydx) rapidly increases as x goes from a to b, then U I,N ~ YI (b) will be large. If f3 is
small in magnitude compared to UI,N. the teIm W2,O = (f3 - UI,N )/VI,N will be approxi-
mately -UI.N/VI,N. The computations in Step 6 then become

UI,N
WI=uI ,I +W20VI'~UI'-
,,' ,I VI , i,
VI,N

Ul,N
W2 = U2 ,I + W2 OV2 . ~ U2
• ,l ,l. - V2,i,
Vl,N

which allows a possibility of a loss of significant digits due to cancellation. However, since
UI,i is an approximation to YI (Xi), the behavior of Yl can easily be monitored, and if Ul,i
increases rapidly from a to b, the shooting technique can be employed backward from
Xo = b to XN = a; that is, solving instead the initial-value problems

y" = p(X)Y' + q(x)y + rex), a ~ X <b, y(b) = f3, y'(b) = 0,

and

y" = p(X)Y' +q(x)y, a <x:::: b, y(b) = 0, y'(b) = 1.


652 C HAP T E R 11 • Boundary-Value Problems for Ordinary Differential Equations

If this reverse shooting technique still gives cancellation of significant digits and if
increased precision does not yield greater accuracy, other techniques must be used, such
as those presented later in this chapter. In general, however, if Ul,i and VI,i are O(h n )
approximations to YI (Xi) and Y2 (Xi), respectively, for each i = 0, 1, ... , N, then Wl,i will
be an O(h n ) approximation to Y(Xi). In particular,

VI .
Iwl,i - y(xi)1 < Kh n
1+ ,t,
VI,N

for some constant K (see [IK, p. 426]).

EXERCISE SET 11.1


1. The boundary-value problem

y" = 4(y - x), 0 <x < 1, yeO) = 0, y(l) = 2,

has the solution y(x) = e 2 (e 4 - l)-l(e2< - e-2<) + x. Use the Linear Shooting method to
approximate the solution, and compare the results to the actual solution.
1
a. With h = !.
2'
b. With h = 4 •

2. The boundary-value problem

y"=y'+2y+cosx, O<x<~, y(O) =-0.3, y(~)=-O.l

has the solution y(x) = - 1~ (sin x + 3 cos x). Use the Linear Shooting method to approximate
the solution, and compare the results to the actual solution.
a. With h = ;; b. With h = ;.
3. Use the LinearShooting method to approximate the solution to the following boundary-value
problems.
a. y"=-3y'+2y+2x+3, O<x<l, y(O) =2, y(I)=I; useh=O.1.
b. yll=-;y'+~y-~lnx, 1 <x <2, y(1)=-~, y(2)=ln2; useh=0.05.
c. y"=-(x+I)y'+2y+(1-x 2 )e- x , O<x<l, y(O)=-I, y(1)=O; useh=O.1.
d. yll=~+!>y+l:X_I, l<x<2,y(1)=y(2)=O;useh=0.1.
4. Although q(x) < 0 in the following boundary-value problems, unique solutions exist and
are given. Use the Linear Shooting Algorithm to approximate the solutions to the following
problems, and compare the results to the actual solutions.
a. y" + y = 0, O::'S x < ;, yeO) = I, y(;) = 1; use h = ;0;
actual solution
y(x) = cosx + (.J2 - I) sinx.
b. y" + 4y = cosx, 0 < x < ;, yeO) = 0, y(;) = 0; use h = ~; actual solution
y(x) = -~ cos2x -1 sin2x + ~ cosx.
c. y" = -;y' - ~y+ -!r lnx, 1 <x< 2, y(1) = ;, y(2) = In2; useh = 0.05; actual
solution y(x) = x4 - !r
x
+ lnx - 3
2•

d. y" = 2y' - Y + xe x - x, 0 < x < 2, yeO) = 0, y(2) = -4; use h = 0.2; actual
solution y(x) = ~x3eX - ~xex + 2ex - x - 2.
11.2 The Shooting Method for Nonlinear Problems 653

S. Use the Linear Shooting Algorithm to approximate the solution y = e- lOx to the boundary-
value problem

y" = l00y, 0 <x < 1, yeO) = 1, y(l) = e- IO •

Use h = 0.1 and 0.05.


6. Write the second-order initial-value problems (11.3) and (11.4) as first-order systems, and
derive the equations necessary to sol ve the systems using the fourth-order Runge· Kutta method
for systems.
7. Let u represent the electrostatic potential between two concentric metal spheres of radii R I and
Rz (RI < R2)' The potential of the inner sphere is kept constant at VI volts, and the potential
of the outer sphere is 0 volts. The potential in the region between the two spheres is governed
by Laplace's equation, which, in this particular application, reduces to

d 2u 2 du
__
dr2
+-
r dr
=0, R I <r<R 2, u(R I ) = VI, U(R2) =0.

Suppose RI = 2 in., R2 = 4 in., and VI = 110 volts.


a. Approximate u(3) using the Linear Shooting Algorithm.
b. Compare the results of part (a) with the actual potential u(3), where

8. Show that, under the hypothesis of Corollary 11.2, if Y2 is the solution to y" = p(x) y' + q (x) y
and Y2(a) = Y2(b) = 0, then Y2 = O.
9. Consider the boundary-value problem

y" +y = 0, 0 <x < b, yeO) = 0, y(b) = B.

Find choices for band B so that the boundary-value problem has


a. No solution;
b. Exactly one solution;
c. Infinitely many solutions.
10. Attempt to apply Exercise 9 to the boundary-value problem

y" - y = 0, o <x < b, yeO) = 0, y(b) = B.

What happens? How do both problems relate to Corollary 11.2?

11.2 The Shooting Method for Nonlinear Problems


The shooting technique for the nonlinear second-order boundary-value problem

y" = f(x, y, y'), a::::: x < b, yea) = 0', y(b) = {3, (1l.6)

is similar to the linear technique, except that the solution to a nonlinear problem cannot be .
expressed as a linear combination of the solutions to two initial-value problems. Instead,
we approximate the solution to the boundary-value problem by using the solutions to a
654 C HAP T E R 11 • Boundary-Value Problems jar Ordinary Differential Equations

sequence of initial-value problems involving a parameter t. These problems have the fonn

yl/=/(x,y,y'), a~x~b, y(a)=a, y'(a)=t. (11:7)

We do this by choosing the parameters t = tk in a manner to ensure that

lim y(b, tk)


k-+oo
= y(b) = p,
where y(x, tk) denotes the solution to the initial-value problem (11.7) with t = tk, and y(x)
denotes the solution to the boundary-value problem (11.6).

Figure 11.2
y

f3
y(b, to) (b, y(b, to»

y(x, to)

Slope to
a (a, a)

a b x

This technique is called a "shooting" method, by analogy to the procedure of firing


objects at a stationary target. (See Figure 11.2.) We start with a parameter to that determines
the initial elevation at which the object is fired from the point (a, a) and along the curve
described by the solution to the initial-value problem:

yl/ = I(x, y, y'), a ~ x ~ b, yea) = a, y'(a) = to.

If y(b, to) is not sufficiently close to p, we correct our approximation by choosing


elevations t\, t2, and so on, until y(b, td is sufficiently close to "hitting" p. (See Figure
11.3.)
To detennine the parameters tb suppose a boundary-value problem of the form (11.6)
satisfies the hypotheses of Theorem 11.1. If y(x, t) denotes the solution to the initial-value
problem (11.7), we next determine t with

y(b, t) - fJ = O. ( 11.8)

This is a nonlinear equation of the type considered in Chapter 2, so a number of methods


are available.
To use the Secant method to solve the problem, we need to choose initial approxima-
tions to and t 1, and then generate the remaining tenns of the sequence by
11.2 The Shooting Methodfor Nonlinear Problems 655

Figure 113
Y

y(b, t 2) Y(X, t 2)
- f3 ------------------- -
y(b, t 3) Y(X, t 3 )

y(b, t I) y(X, t I)
y(b, to) y(X, to)

a (a, a)

a b x

To use the more powerful Newton's method to generate the sequence {tk}, only one
initial approximation, to, is needed. However, the iteration has the form
y(b, tk-d - f3
tk = tk-I - d ' (11.9)
¥,(b, tk-I)
and it requires the knowledge of (dyjdt)(b, tk-I). This presents a difficulty since an ex-
plicit representation for y(b, t) is not known; we know only the values y(b, to), y(b, tl)'
... , y(b, tt-I).
Suppose we rewrite the initial-value problem (11.7), emphasizing that the solution
depends on both x and the parameter t:

y"(X, t) = f(x, y(x, t), y'(x, t», a::5 x ::5 b, yea, t) = a, y'(a, t) = t. (11.10)

We have retained the prime notation to indicate differentiation with respect to x. Since
we need to determine (dyjdt)(b, t) when t = tk-I, we first take the partial derivative of
(11.10) with respect to t. This implies that
ay" af ,
a (x,t)= (x,y(x,t),y(x,t»
t at
af ,ax af ,ay
= ax (x, y(x, t), y (x, t» at + ay (x, y(x, t), y (x, t» at (x, t)

af ,ay'
+ (x,y(x,t),Y(X,t» (X,t).
oy' at
Since x and t are independent, ax j at = 0 and
ay" af ,ay af ,ay'
a (X,t) = a (x,y(x,t),y(x,t»a (X,t)+ a (x,y(x,t),y(x,t» (x,t),
t y t y' at
(11.11)
656 C HAP T E R 11 • Boundary-Value Problems for Ordinary Differential Equations

for a < x < b. The initial conditions give

ay ay'
-(a, t) =0 and -(a, t) = 1.
at at
If we simplify the notation by using z(x, t) to denote (ay / at) (x , t) and assume that
the order of differentiation of x and t can be reversed, (11.11) with the initial conditions
becomes the initial-value problem

/I af , af , ,
Z (x,t)= (x,y,y)z(x,t)+ (x,y,y)z(x,t), (1l.l2)
ay ay'
a::: x <b, z(a, t) = 0, z'(a, t) = 1.

Newton's method therefore requires that two initial-value problems be solved for each
iteration, (1l.l0) and (11.12). Then from Eq. (11.9),

y(b, tk-I) - fJ
tk = tk-I - . (1l.l3)
z(b, tk-I)

Of course, none of these initial-value problems is solved exactly; the solutions are ap-
proximated by one of the methods discussed in Chapter 5. Algorithm 11.2 uses the Runge-
Kutta method of order four to approximate both solutions required by Newton's method.
A similar procedure for the Secant method is considered in Exercise 4.

Nonlinear Shooting with Newton's Method


To approximate the solution of the nonlinear boundary-value problem

y" = f(x, y, y'), a::: x ::: b, yea) = IX, y(b) = fJ :


(Note: Equations (11.10) and (11.12) are written as first-order systems and solved.)
INPUT endpoints a, b; boundary conditions IX, fJ; number of subintervals N > 2; toler-
ance TOL; maximum number of iterations M.
OUTPUT approximations WI,; to y(x;); WZ,; to y'(x;) for each i = 0,1,.,. , N or a
message that the maximum number of iterations was exceeded.

Step 1 Seth = (b-a)/N;


k = 1;
TK = (fJ - a)/(b - a). (Note: TK could also be input.)
Step 2 While (k < M) do Steps 3-10.

Step 3 Set WI,O = IX;


Wz,O = TK;
UI = 0;
Uz = 1.
Step 4 For i = 1, ... , N do Steps 5 and 6.
(The Runge-Kutta method for systems is used in Steps 5 and 6.)
11.2 The Shooting Methodfor Nonlinear Problems 657

Step 5 Setx = a + (i - l)h.

Step 6 Setkll. = hWZi-l;


,

k1,2 = hf(x, WI,i-1 WZ,i-I);

kz,1 = h (WZ,i-1 + 1k l,z);


kz,z = hf (x + h12, Wl,i-l + ikl,l, WZ,i-1 + ~k1,2);
k3,1 = h (WZ,i-1 + ~kz,z);
k3,Z = + h12, WI,i-1 + ~kZ,I' WZ,i-1 + ~k2,2);
hf (x
k4.1 = h(W2,i-l + k3.Z);

k4.2 = hf(x + h, WI,i-1 + k3.1, WZ,i-1 + k3,2);


WI,i = WI,i-1 + (kl,l + 2kz ,1 + 2k3,1 + k 4. 1)/6;

WZ,i = WZ,i-1 + (ki,2 + 2kz ,z + 2k 3,z + k 4 ,2) /6;

k; I
, = huz;
k;,z = h[fy(x, WI,i-l, WZ,i-I)UI

+f y' (x, Wl,i-I, WZ,i-1 )uz];


k;,1 = h [uz + ~k;,2];

k;,2 = h [fy(x + h/2, WI,i-l, WZ,i-l) (UI + ~k;,l)


+h(x + h/2, WI,i-l, WZ,i-l) (U2 + ~k;.z)];
k~,1 = h (uz + ~k;,2);
k~,z = h [fy(x + h/2, WI,i-l, WZ,i-l) (UI + ~k;,I)
+ h(x + h/2, WI,i-l, W2,i-l) (U2 + ~k;,2)];
k~,1 = h(U2 + k~,2);
k~,2 = h [fy(x + h, Wl,i-I, WZ,i-l) (Ul + k~,I)
+h(x + h, Wl,i-I, W2,i-l) (U2 + k~,z)];
UI = UI + ~[k;,1 + 2k;.1 + 2k~,1 + k~.d;

Uz = Uz + ~ [k;,2 + 2k;,2 + 2k~,2 + k~,21.


Step 7 If IWI,N -.81 < TOL then do Steps 8 and 9.

Step 8 For i = 0, 1, ... , N


set x = a + ih;
OUTPUT (x, WI,i, W2,i)·

Step 9 (The procedure is complete.)


STOP.

Step 70 Set TK = TK _ wl,N -.8;


Ul
(Newton's method is used to compute TK.)
k=k+l.
658 C HAP T E R 11 • Boundary-Value Problemsfor Ordinary Differential Equations

Step 11 OUTPUT ('Maximum number of iterations exceeded');


(The procedure was unsuccessful.)
STOP. •
The value to = TK selected in Step 1 is the slope of the straight line through Ca, a)
and Cb, fJ). If the problem satisfies the hypotheses of Theorem 11.1, any choice of to will
give convergence, but a good choice of to will improve convergence, and the procedure will
work for many problems that do not satisfy these hypotheses.

EXAMPLE 1 Consider the boundary-value problem

1 3' 43
Y = 8 (32 + 2x - yy ),
1/
I :::: x < 3, y(1) = 17, y(3) = 3 '

which has the exact solution y(x) = x 2 + 16/x.


Applying the Shooting method given in Algorithm 11.2 to this problem requires ap-
proximating solutions to the initial-value problems

Y1/ = 81 (32 + 2x 3 - yy ') , 1:::: x <3, y(1) = 17, y'(I) = tk,

and

Z
" = ay
at Z + ay'Z
at, = - 81"
(y Z + yz), 1:::: x <3, z(1
) = 0, Z
' (1) = 1,

Table 11.2 Xj WI· Y(Xj) IWI. , - y(xj)1


,I

1.0 17.000000 17.000000


1.1 15.755495 15.755455 4.06 x 10- 5
1.2 14.773389 14.773333 5.60 x 10- 5
1.3 13.997752 13.997692 5.94 x 10- 5
1.4 13.388629 13.388571 5.71 x 10-5
1.5 12.916719 12.916667 5.23 x 10- 5
1.6 12.560046 12.560000 4.64 x 10-5
1.7 12.301805 12.301765 4.02 x 10- 5
1.8 12.128923 12.128889 3.14 x 10-5
1.9 12.031081 12.031053 2.84 x 10- 5
2.0 12.(X)OO23 12.000000 2.32 x 10-5
2.1 12.029066 12.029048 1.84 x 10- 5
2.2 12.112741 12.112727 1.40 x 10-5
2.3 12.246532 12.246522 1.01 x 10- 5
2.4 12.426673 12.426667 6.68 x 10- 6
2.5 12.650004 12.650000 3.61 x 10-6
2.6 12.913847 12.913845 9.17 x 10- 7
2.7 13.215924 13.215926 1.43 x 10- 6
2.8 13.554282 13.554286 3.46 x 10-6
2.9 13.927236 13.927241 5.21 x 10-6
3.0 14.333327 14.333333 6.69 x 10-6
11.2 The Shooting Method for Nonlinear Problems 659

at each step in the iteration. If the stopping technique requires

then we need four iterations and t4 = -14.000203. The results obtained for this value of t
are shown in Table 11.2. •

Although Newton's method used with the shooting technique requires the solution
of an additional initial-value problem, it will generally give faster convergence than the
Secant method. Both me~ods are only locally convergent since they require good initial
approximations. For a general discussion of the convergence of the shooting techniques
for nonlinear problems, the reader is referred to the excellent book by Keller [Keller. H).
In that reference, more general boundary conditions are discussed. It is also noted that the
shooting technique for nonlinear problems is sensitive to roundoff errors, especially if the
solution y(x) and z(x, t) are rapidly increasing functions of x on [a, b).

EX ERe I S ESE T 11.2


1. Use the Nonlinear Shooting Algorithm with h = O.S to approximate the solution to the
boundary-value problem

y" = _(y')2 _ Y + Inx. 1 <x < 2, y(1) = 0, y(2) = In2.


Compare your results to the actual solution y = In x.
2. Use the Nonlinear Shooting Algorithm with h = 0.25 to approximate the solution to the
boundary-value problem

1 1
Y" = 2y,3 -1 < x :::: 0, y(-I)=2' yeO) = 3'
= 1/(x + 3).
Compare your results to the actual solution y(x)
3. Use the Nonlinear Shooting method with TOL = 10-4 to approximate the solution to the fol-
lowing boundary-value problems. The actual solution is given for comparison to your results.
a. y" = y3 - yy', 1 < x < 2, y(1) = ~, y(2) = t; use h = 0.1; actual solution
y(x) = (x + I)-I.
b. y" = 2 y 3 - 6y - 2x 3 , 1:::: x < 2, y(l) = 2, y(2) = ~; use h = 0.1; actual solution
y(x) = x + X-I
c. y" = y' + 2(y -lnx)3 - X-I, 2 <x < 3, y(2) = ; + In2, y(3) = ~ + In3; use
h = 0.1; actual solution y(x) = X-I + lnx.

d. y" = [x2(y')2 - 9y2 + 4x 6 J1x 5 , 1 < x < 2, y(l) = 0, y(2) = In256; use h = 0.05;
actual solution y(x) = x 3 1nx.
4. Change Algorithm 11.2 to incorporate the Secant method instead of Newton's method. Use
to = (f3 - a)/(b - a) and tl = to + (f3 - y(b, to»/(b - a).
5. Repeat Exercise 3(a) and 3(c) using the Secant algorithm derived in Exercise 4, and compare
the number of iterations required for the two methods.
660 C HAP T E R 11 • Boundary-Value Problems for Ordinary Differential Equations

6. The Van der Pol equation,

y" - f..t(y2 - l)y' +y = 0, f..t > 0,

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.

11.3 Finite-Difference Methods for Linear Problems


The linear and nonlinear Shooting methods for boundary-value problems can present prob-
lems of instability. The methods in this section have better stability characteristics, but they
generally require more computation to obtain a specified accuracy.
Methods involving finite differences for solving boundary-value problems replace
each of the derivatives in the differential equation with an appropriate difference-quotient
approximation of the type considered in Section 4.1. The particular difference quotient and
step size h are chosen to maintain a specified order of truncation error. However, h cannot
be chosen too small because of the instability of the derivative approximations.
The finite difference method for the linear second-order boundary-value problem,

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

y" (Xi) = P (Xi) y' (Xi) + q (Xi) Y (Xi) + r (Xi)· (11.15)

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 ~t in (Xi, Xi+I), and

You might also like