(Chapter 4) Shooting Method

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 14

Chapter 4

Shooting Method

4.1 Introduction
The shooting method is an alternative numerical method for solving
boundary value problems (BVPs). The basic idea is to convert the
BVP into two initial value problems (IVPs) that can be solved using
the technique developed in Chapter 1.
For linear BVPs, the shooting method takes a linear combination
of solution to two IVPs. The specific form of the IVPs and the com-
bination of its solution is specified by the type of boundary conditions
given.
The shooting method for nonlinear BVPs lead to an iterative process
for which the secant method or Newton’s method can be used.

4.2 Linear Second Order BVP


4.2.1 Dirichlet Boundary Conditions
Consider linear second order differential equation of the form

y 00 = p(x)y 0 + q(x)y + r(x), x0 ≤ x ≤ xN , (4.1)

with boundary conditions

y(x0) = α, y(xN ) = β. (4.2)


50 CHAPTER 4. SHOOTING METHOD

If r(x) 6= 0, the differential equation is called nonhomogeneous. So the


homogeneous differential equation is
y 00 = p(x)y 0 + q(x)y. (4.3)
The differential equation (4.1) with boundary conditions (4.2) has
a unique solution if and only if p(x), q(x) and r(x) are continuous and
the values of q(x) are positive. To estimate the unique solution to the
boundary value problem, first we consider the following initial value
problems.
The first initial value problem (IVP1) is
u00 = p(x)u0 + q(x)u + r(x), x0 ≤ x ≤ xN ,
(4.4)
u(x0 ) = α, u0(x0 ) = 0.
The second initial value problem (IVP2) is
v 00 = p(x)v 0 + q(x)v, x0 ≤ x ≤ xN ,
(4.5)
v(x0) = 0, v 0(x0) = 1.
From the basic theory of linear differential equation, we know that
a linear combination of the solutions of these two initial problems will
also be a solution of the nonhomogeneous differential equation.
In fact we can verify that any function of the form
y(x) = u(x) + sv(x), (4.6)
not only satisfy the nonhomogeneous differential equation, but also
satisfies the initial condition y(x0) = α.
Substitute x = xN into equation (4.6) we have
y(x0) = u(xN ) + sv(xN ).
If v(xN ) 6= 0, then
β − u(xN )
s= . (4.7)
v(xN )
So that, the solution of the original two-point boundary value problem
is given by
h β − u(x ) i
N
y(x) = u(x) + v(x),
v(xN ) (4.8)
x0 ≤ x ≤ xN .
4.2. LINEAR SECOND ORDER BVP 51

On the other hand, if v(xN ) = 0, the solution u(x) satisfies both of the
boundary conditions.
The system of two first order initial value problem, can be solved
by using single step method.

Example 4.1 Solve the following boundary value problem using linear
shooting method. Use Euler method to solve the corresponding initial
value problems.

y 00 + xy 0 − 3y = 4.2x, 0 ≤ x ≤ 1,
y(0) = 0, y(1) = 1, and h = 0.25.

Example 4.2 Use the linear shooting method to approximate the solu-
tion of the following boundary value problem. Solve the corresponding
initial value problem using midpoint method.

y 00 = 4(y − x), 0 ≤ x ≤ 1,
y(0) = 0, y(1) = 2, and h = 0.25.

Example 4.3 Solve the following boundary value problem using linear
shooting method. Use Heun’s method to solve the corresponding initial
value problems.

y 00 = 2y 0 + y + xex − x, 0 ≤ x ≤ 2,
y(0) = 0, y(2) = −4, and h = 1.

Example 4.4 Write the linear shooting method algorithm to solve the
following boundary value problem.
π
y 00 = y 0 + 2y cos x, 0 ≤ x ≤ ,
π 2
π
y(0) = −0.3, y = −0.1, and h = .
2 16
Use optimal RK2 method to solve the corresponding initial value prob-
lems.

Example 4.5 Write the linear shooting method algorithm to solve the
following boundary value problem. Use the fourth order Runge-Kutta
52 CHAPTER 4. SHOOTING METHOD

method to solve the corresponding initial value problems.


 x
y 00 − 1 − y = x, 1 ≤ x ≤ 3,
5
y(1) = 2, y(3) = −1, and h = 0.1.

4.2.2 Neumann Boundary Conditions


Consider linear second order differential equation (4.1) with boundary
condition

y(x0) = α, y 0(xN ) = θ. (4.9)


To find unique solution to these boundary value problem, we need
to consider the initial value problem (4.4) and (4.5). The equation (4.6)
satisfies the conditions at x = x0 since y(x0) = α. We need to find s (if
possible), so that y(x) satisfies

y 0 (xN ) = u0 (xN ) + sv 0(xN ). (4.10)

If v 0(xN ) 6= 0, then
θ − u0(xN )
s= . (4.11)
v 0(xN )
Then the solution of the original two point boundary value problems is
given by
h θ − u0(x ) i
N
y(x) = u(x) + v(x),
v 0(xN ) (4.12)
x0 ≤ x ≤ xN .

Example 4.6 Use the linear shooting method to approximate the so-
lution of the indicated boundary value problems. Write out the initial
value problems that must be solved, then solve the initial value prob-
lems using Euler method.

(i) y 00 = 4(y − x), 0 ≤ x ≤ 1,


y(0) = 0, y 0 (1) = 31, and h = 0.25.
4.2. LINEAR SECOND ORDER BVP 53

(ii) y 00 = y 0 + 2y + cos x, 0 ≤ x ≤ 1,
y(0) = −0.3, y 0(1) = 0.3, and h = 0.25.

Example 4.7 Write the linear shooting method algorithm to solve the
following boundary value problem. Use midpoint method to solve the
corresponding initial value problems.
y 00 = −2y 0 − 4y, 0 ≤ x ≤ 1,
y(0) = 2, y 0(1) = 2, and h = 0.2.

4.2.3 Robin Boundary Conditions


Consider linear second order differential equation (4.1) with boundary
conditions
α0 y(x0) + α1 y 0 (x0) = α2, (4.13)
and
β0 y(xN ) + β1 y 0(xN ) = β2. (4.14)
To find unique solution to these boundary value problem, we need to
consider the following initial value problems.
(i) (IVP1),

u00 = p(x) u0 + q(x) u + r(x), x0 ≤ x ≤ xN ,


(4.15)
u(x0) = 0, u0(x0 ) = 0.

(ii) (IVP2),
v 00 = p(x) v 0 + q(x) v, x0 ≤ x ≤ xN ,
(4.16)
v(x0) = 1, v 0(x0) = 0.

(iii) (IVP3),
w00 = p(x) w0 + q(x) w, x0 ≤ x ≤ xN ,
(4.17)
w(x0) = 0, w0(x0 ) = 1.

Let u(x), v(x) and w(x) are the solutions of the initial value prob-
lems (4.15), (4.16) and (4.17) respectively. Now let

y(x) = u(x) + s1 v(x) + s2 w(x), (4.18)


54 CHAPTER 4. SHOOTING METHOD

as the solution of the boundary value problem (4.1) with boundary


conditions (4.13) and (4.14).
Differentiate equation (4.18) with respect to x, we have

y 0 (x) = u0(x) + s1 v 0(x) + s2 w0 (x). (4.19)

From equations (4.13), (4.18) and (4.19), when x = x0,

α0 y(x0) + α1 y 0(x0 ) = α0 [u(x0) + s1 v(x0) + s2 w(x0 )]


+ α1 [u0(x0) + s1 v 0(x0 ) + s2 w0 (x0)],
or
α2 = α0 s1 + α2 s2, (4.20)
by applying the initial conditions in (4.15) to (4.17).
From equations (4.14), (4.18) and (4.19), when x = xN ,

β0 y(xN ) + β1 y 0(xN ) = β0 [u(xN ) + s1 v(xN ) + s2 w(xN )]


+ β1 [u0(xN ) + s1 v 0(xN ) + s2 w0 (xN )],
or
β2 = β2 u(xN ) + β1 u0 (xN ) + s1 [β0 v(xN ) + β1 v 0(xN )]
(4.21)
+ s2 [β0 w(xN ) + β1 w0 (xN )].

Solve equations (4.20) and (4.21), to get s1 and s2 . Finally write


the solution

y(xi) = u(xi) + s1 v(xi ) + s2 w(xi ), i = 0, 1, 2, . . . , N. (4.22)

Example 4.8 Solve the following boundary value problems using lin-
ear shooting method. Use Euler’s method to solve the corresponding
initial value problems.
(i) y 00 − xy 0 − y = x2, 0 ≤ x ≤ 1,
0 0
y (0) = 0, y (1) = 1, and h = 0.25.
π
(ii) y 00 = y + sin(3x), 0≤x≤ ,
2
π π
y(0) + y 0(0) = −1, y 0 = 1, and h = .
2 8
4.3. NONLINEAR SECOND ORDER BVP 55

Example 4.9 Use the linear shooting method to approximate the so-
lution of the indicated boundary value problems. Write out the initial
value problems that must be solve. Then solve these initial value prob-
lems using midpoint method.
(i) y 00 = y + x, 0 ≤ x ≤ 1,
y(0) + y 0(0) = 0.5, y(1) − 2y 0(1) = 0, and h = 0.25.
(ii) y 00 + xy 0 + y = x2, 0 ≤ x ≤ 1,
0
y(0) + y (0) = 0, y(1) + y 0 (1) = 1, and h = 0.25.

(iii) y 00 − y = 1, 0 ≤ x ≤ 1,
1
y(0) − y 0 (0) = 1, y(1) + y 0 (1) = 1, and h = 0.25.
2

4.3 Nonlinear Second Order BVP


The shooting method for the nonlinear second order boundary value
problem,
y 00 = f(x, y, y 0), x0 ≤ x ≤ xN , (4.23)
with boundary conditions (4.2) or (4.9), is similar to the linear shoot-
ing method, except that the solution to the nonlinear boundary value
problem cannot be expressed as a linear combination of the solutions
to two initial value problems.
We approximate the solution to the nonlinear boundary value prob-
lem using the solution to a sequence of initial value problems involving
a parameter s where s is a shooting direction.
First we write our initial value problem as
u00 = f(x, u, u0), x0 ≤ x ≤ xN ,
(4.24)
u(x0) = α, u0(x0 ) = s,

where u(x) represent y(x). Then convert the differential equation (4.24)
to a system of first order differential equation. Let
u0 = v, u(x0) = α,
(4.25)
v 0 = f(x, u, v), v(x0) = s.
56 CHAPTER 4. SHOOTING METHOD

u(x, s) is the solution of the nonlinear differential equation (4.23) with


boundary conditions (4.2) or (4.9) if and only if

φ(s) = u(xN , s) − β = 0, (4.26)

or
φ(s) = v(xN , s) − θ = 0. (4.27)
We can use secant or Newton’s method to improve the value of shooting
direction, s.

4.3.1 Secant Method


Secant iteration formula can be written as
φ(si )(si − si−1 )
si+1 = si − , i = 1, 2, . . . , (4.28)
φ(si ) − φ(si−1 )

where s0 and s1 are initial guesses and we define φ(s) from equation
(4.26) or (4.27).
If we have nonlinear differential equation (4.23) with boundary con-
ditions (4.2), then we can rewrite equation (4.28) as

[u(xN , si ) − β](si − si−1 )


si+1 = si − , i = 1, 2, . . . . (4.29)
u(xN , si ) − u(xN , si−1 )

Similarly if we have nonlinear differential equation (4.23) with boundary


condition (4.9), then we can rewrite equation (4.28) as

[v(xN , si ) − θ](si − si−1 )


si+1 = si − , i = 1, 2, . . . . (4.30)
v(xN , si ) − v(xN , si−1 )

Therefore if we want to estimate the solution of nonlinear second


order boundary value problem, we need to solve the following initial
value problems. The first initial value problem (IVP1) is

u00 = f(x, u, u0), x0 ≤ x ≤ xN ,


(4.31)
u(x0) = α, u0(x0 ) = s0 ,
4.3. NONLINEAR SECOND ORDER BVP 57

and the second initial value problem (IVP2) is


u00 = f(x, u, u0), x0 ≤ x ≤ xN ,
(4.32)
u(x0) = α, u0(x0 ) = s1 .
Then we use equation (4.29) or (4.30) to compute s2 and solve the
corresponding initial value problems. Proceed your calculation until
|si+1 − si | < , (4.33)
or
|u(xN , si ) − α| < , (4.34)
or
|v(xN , si ) − θ| < , (4.35)
where  is a given tolerance.

Example 4.10 Solve the following nonlinear boundary value problem


using shooting method. Use Euler method to solve the corresponding
initial value problems and secant method to improve shooting direction,
s with s0 = 1 and s1 = 0.75. Stop your iteration when |si+1 −si | < 0.05.
y 00 + (y 0)2 = 0, 0 ≤ x ≤ 1,
y(0) = 0, y(1) = 1, and h = 0.25.
Example 4.11 Solve the following nonlinear boundary value prob-
lem using shooting method. Use midpoint method to solve the corre-
sponding initial value problems and secant method to improve shooting
direction,s with s0 = 1.5 and s1 = 2.5. Calculate until s3 .
yy 00 + (y 0)2 = −1, 1 ≤ x ≤ 2,
y(1) = 1, y 0(2) = 0.5, and h = 0.25.
Example 4.12 Solve the following nonlinear boundary value problem
using shooting method. Use Heun method to solve the corresponding
initial value problems and secant method to improve shooting direction,
(β − α) (β − u(xN , s0 ))
s2 with s0 = and s1 = s0 + .
(xN − x0) xN − x0
y 00 + y y 0 = y 3, 1 ≤ x ≤ 2,
y(1) = 0.5, y(2) = 0.3, and h = 0.25.
58 CHAPTER 4. SHOOTING METHOD

Example 4.13 Write an algorithm to solve the following boundary


value problem using shooting method. Assume that we use Ralston’s
method to solve the corresponding initial value problems and secant
(θ − α)
method to improve shooting direction, s where s0 = and
(xN − x0 )
(θ − v(xN , s0))
s1 = s0 + . Apply stopping criteria |si+1 − si | < 0.005.
xN − x0
y 00 = 2y 3 − 6y − 2x3 , 1 ≤ x ≤ 2,
y(1) = 2, y 0(2) = 0.75, and h = 0.2.
Example 4.14 Write an algorithm to solve the following boundary
value problem using shooting method. Assume that we use fourth order
Runge-Kutta method to solve the corresponding initial value problems
and secant method to improve shooting direction, s. Apply stopping
criteria |si+1 − si | < 0.005.
(i) y 00 + (y 0)2 + y = ln x, 1 ≤ x ≤ 2,
y(1) = 0, y(2) = ln 2, and h = 0.1
(ii) y 00 = 2y 3 , −1 ≤ x ≤ 0,
y(−1) = 0.5, y 0(0) = −0.1, and h = 0.1

4.3.2 Newton’s Method


Newton’s iteration formula can be written as
φ(si )
si+1 = si − , i = 0, 1, 2, . . . , (4.36)
φ0(si )

where s0 is the initial guess and φ0 (s) = . We define φ(s) from
ds
equation (4.26) or (4.27).
If we have nonlinear differential equation (4.23) with boundary con-
ditions (4.2), then using equation (4.26), we have
dφ d[u(xN , s) − β]
φ0 (s) = =
ds ds (4.37)
du(xN , s) ∂u(xN , s)
= = .
ds ∂s
4.3. NONLINEAR SECOND ORDER BVP 59

If we have nonlinear differential equation (4.23) with boundary con-


ditions (4.9), then using equation (4.27), we have

dφ d[v(xN , s) − β]
φ0(s) = =
ds ds (4.38)
dv(xN , s) ∂v(xN , s)
= = .
ds ∂s
∂u(xN , s) ∂v(xN , s) ∂u(x, s)
We need to estimate and . Let z1(x) =
∂s ∂s ∂s
∂v(x, s)
and z2(x) = . Then
∂s
dz1 d  ∂u 
z10 (x) = =
dx dx ∂s (4.39)
∂  du  ∂v
= = = z2(x),
∂s dx ∂s
and
dz2 d  ∂v 
z20 (x) = =
dx dx ∂s
∂  dv  ∂f(x, u, v)
= =
∂s dx ∂s (4.40)
∂f ∂u ∂f ∂v
= · + ·
∂u ∂s ∂v ∂s
∂f ∂f
= z1(x) + z2(x) .
∂u ∂v
Furthermore,
∂u(x0, s) ∂α
z1(x0 ) = = = 0, (4.41)
∂s ∂s
and
∂v(x0, s) ∂s
z2 (x0) = = = 1. (4.42)
∂s ∂s
So that we need to solve the following initial value problem to estimate
the value of z1(xN ) or z2(xN ).

z10 (x) = z2 (x), z1(x0 ) = 0,


∂f ∂f (4.43)
z20 (x) = z1 (x) + z2(x) , z2 (x0) = 1.
∂u ∂v
60 CHAPTER 4. SHOOTING METHOD

Therefore if we have nonlinear differential equation (4.23) with bound-


ary conditions (4.2), we can rewrite equation (4.36) as,
[u(xN , si ) − β]
si+1 = si − , i = 0, 1, 2, . . . . (4.44)
z1(xN )
If we have nonlinear differential equation (4.23) with boundary con-
dition (4.9), we can rewrite equation (4.36) as,
[v(xN , si ) − θ]
si+1 = si − , i = 0, 1, 2, . . . . (4.45)
z2(xN )
Proceed your calculation until satisfy stopping criteria (4.33) or (4.34)
or (4.35).

Example 4.15 Solve the following nonlinear boundary value problem


using shooting method. Use Euler method to solve the corresponding
initial value problems and Newton’s method to improve your shooting
direction until s2 . Given s0 = 0.
y 00 + xy 0 − 2y 3 = 3x, 0 ≤ x ≤ 1,
y(0) = 1, y(1) = 1.8, and h = 0.25.
Example 4.16 Solve the following nonlinear boundary value problem
using shooting method. Use midpoint method to solve the correspond-
ing initial value problems and Newton’s method to improve your shoot-
ing direction until s2. Given s0 = 0.
y 00 + yy 0 = y 3, 1 ≤ x ≤ 2,
y(1) = 0.5, y(2) = 0.3, and h = 0.25.
Example 4.17 Write an algorithm to solve the following boundary
value problem using shooting method. Assume that we use fourth order
Runge-Kutta method to solve the corresponding initial value problems
and Newton’s method to improve your shooting direction, s. Apply
stopping criteria |si+1 − si | < 0.005. Given s0 = 0.

2xy 00 + (y 0)2 − 4y = 4x, 1 ≤ x ≤ 2,


y(1) = 4, y 0(2) = 6, and h = 0.2.
4.3. NONLINEAR SECOND ORDER BVP 61

Example 4.18 Solve the following nonlinear boundary value problem


using shooting method. Use Euler method to solve the corresponding
initial value problems and secant method to improve your shooting
direction, s. Given s0 = 0 and s1 = 1. Calculate until s3 .

y 00 = 2y 3 , 0 ≤ x ≤ 1,
3y(0) − 9y 0(0) = 2, y(1) = 0.25, and h = 0.25.

(Hint: Use substitution z = 1 − x).

Example 4.19 Write an algorithm to solve the following boundary


value problem using shooting method. Assume that we use Heun
method to solve the corresponding initial value problems and New-
ton’s method to improve your shooting direction, s. Apply stopping
criteria |si+1 − si | < 0.005. Given s0 = 0.5.

y 00 + 2y 2 − 8x2 y 3 = 0, 0 ≤ x ≤ 1,
y(0) + y 0(0) = 1, y(1) = 0.5, and h = 0.2.
62 CHAPTER 4. SHOOTING METHOD

You might also like