Notes - 7the Shooting Method For Solving BVPs
Notes - 7the Shooting Method For Solving BVPs
Notes - 7the Shooting Method For Solving BVPs
= f(x, y, y
= z
z
= f(x, y, z)
y(a) =
y(b) = .
(7.2)
The BVP (7.2) will turn into an IVP if we replace the boundary condition at x = b with the
condition
z(a) = , (7.3)
where is some number. Then we can solve the resulting IVP by any method that we have
studied in Lecture 5, and obtain the value of its solution y(b) at x = b. If y(b) = , then we
have solved the BVP. Mostly likely, however, we will nd that after the rst try, y(b) = .
Then we should choose another value for and try again. There is actually a strategy of how
the values of need to be chosen. This strategy is simpler for linear BVPs, so this is the case
we consider next.
7.2 Shooting method for the Dirichlet problem of linear BVPs
Thus, our immediate goal is to solve the linear BVP
y
+ P(x)y
+ Pu
+ Qu = R,
u(a) = , u
(a) = 0
(7.5)
and
v
+ Pv
+ Qv = 0,
v(a) = 0, v
(a) = 1 ,
(7.6)
where we omit the arguments of P(x) etc. as this should cause no confusion. Next, consider
the function
w = u + v, = const . (7.7)
Using Eqs. (7.5) and (7.6), it is easy to see that
(u + v)
+ P (u + v)
+ Q(u + v) = R,
(u + v)(a) = , (u + v)
(a) = ,
(7.8)
MATH 337, by T. Lakoba, University of Vermont 70
i.e. w satises the IVP
w
+ Pw
+ Qw = R,
w(a) = , w
(a) = .
(7.9)
Note that the only dierence between (7.9) and (7.4) is that in (7.9), we know the value of w
at x = a but do not know whether w(b) = . If we can choose in such a way that w(b) does
equal b, this will mean that we have solved the BVP (7.4).
To determine such a value of , we rst solve the IVPs (7.5) and (7.6) by an appropriate
method of Lecture 5 and nd the coresponding values u(b) and v(b). We then choose the value
=
0
by requiring that the corresponding w(b) = , i.e.
w(b) = u(b) +
0
v(b) = . (7.10)
This w(x) is the solution of the BVP (7.4), because it satises the same ODE and the same
boundary conditions at x = a and x = b; see Eqs. (7.9) and (7.10). Equation (7.10) yields the
following equation for the
0
:
0
=
u(b)
v(b)
. (7.11)
Thus, solving only two IVPs (7.5) and (7.6) and constructing the new function w(x) ac-
cording to (7.7) and (7.11), we obtain the solution to the linear BVP (7.4).
Consistency check: In (7.4), we have required that Q(x) 0, which guarantees that a
unique solution of that BVP exists. What would have happened if we had overlooked to impose
that requirement? Then, according to Theorem 6.2, we could have run into a situation where
the BVP would have had no solutions. This would occur if
v(b) = 0 . (7.12)
But then Eqs. (7.6) and (7.12) would mean that the homogeneous BVP
v
+ Pv
+ Qv = 0,
v(a) = 0, v(b) = 0 ,
(7.13)
must have a nontrivial
16
solution. The above considerations agree, as they should, with the
Alternative Principle for the BVPs, namely: the BVP (7.4) may have no solutions if the
corresponding homogeneous BVP (7.13) has nontrivial solutions.
7.3 Generalizations of the shooting method for linear BVPs
If the BVP has boundary conditions other than of the Dirichlet type, we will still proceed
exactly as we did above. For example, suppose we need to solve the BVP
y
+ Py
+ Qy = R,
y(a) = , y
(b) = ,
(7.14)
which has the Neumann boundary condition at the right end point. Denote y
1
= y, y
2
= y
,
and rewrite this BVP as
y
1
= y
2
y
2
= Py
2
Qy
1
+ R
y
1
(a) = , y
2
(b) = .
(7.15)
16
Indeed, since we also know that v
y
1
y
2
,
we can further rewrite this BVP as
y
0 1
Q P
y +
0
R
,
y
1
(a) =
y
2
(b) = .
(7.16)
Now, in analogy with Eqs. (7.5) and (7.6), consider two auxiliary IVPs:
u
0 1
Q P
u +
0
R
, u(a) =
; (7.17)
v
0 1
Q P
v , v(a) =
0
1
. (7.18)
Solve these IVPs by an appropriate method and obtain the values u(b) and v(b). Next, consider
the vector
w = u + v, = const. (7.19)
Using Eqs. (7.17)(7.19), it is easy to see that this new vector satises the IVP
w
0 1
Q P
w +
0
R
, w(a) =
. (7.20)
At x = b, its value is
w(b) =
u
1
(b) + v
1
(b)
u
2
(b) + v
2
(b)
, (7.21)
where u
1
is the rst component of u etc. From the last equation in (7.16), it follows that we
are to require that
w
2
(b) = . (7.22)
Equations (7.21) and (7.22) together yield
u
2
(b) + v
2
(b) = , (7.23)
0
=
u
2
(b)
v
2
(b)
. (7.24)
Thus, the vector w given by Eq. (7.19) where u, v, and satisfy Eqs. (7.17), (7.18), and
(7.24), respectively, is the solution of the BVP (7.16).
Also, the shooting method can be used with IVPs of order higher than the second. For
example, consider the BVP
x
3
y
+ xy
y = 3 + ln x,
y(a) = , y
(b) = , y
(b) = .
(7.25)
As in the previous example, denote y
1
= y, y
2
= y
, y
3
= y
= Ay +r ,
y
1
(a) =
y
2
(b) =
y
3
(b) = .
(7.26)
MATH 337, by T. Lakoba, University of Vermont 72
where
y =
y
1
y
2
y
3
, A =
0 1 0
0 0 1
1
x
3
1
x
2
0
, r =
0
0
3+lnx
x
3
.
Consider now three auxiliary IVPs:
u
= Au +r ,
u(a) =
0
0
;
v
= Av ,
v(a) =
0
1
0
;
w
= A w,
w(a) =
0
0
1
.
(7.27)
Solve them and obtain u(b), v(b), and w(b). Then, construct z = u +v + w, where and
are numbers which will be determined shortly. At x = b, one has
z(b) =
. . .
u
2
(b) + v
2
(b) + w
2
(b)
u
3
(b) + v
3
(b) + w
3
(b)
. (7.28)
If we require that z satisfy the BVP (7.26), we must have
z(b) =
. . .
. (7.29)
From Eqs. (7.28) and (7.29) we form a system of two linear equations for the unknown coe-
cients and :
v
2
(b) + w
2
(b) = u
2
(b) ,
v
3
(b) + w
3
(b) = u
3
(b) .
(7.30)
Solving this linear system, we obtain values
0
and
0
such that the corresponding z = u +
0
v +
0
w solves the BVP (7.26) and hence the original BVP (7.25).
7.4 Caveat with the shooting method, and its remedy, the multiple
shooting method
Here we will encounter a situation where the shooting method in its form described above does
not work. We will also provide a way to modify the method so that it would be usable again.
Let us consider the BVP
y
= 30
2
(y 1 + 2x) ,
y(0) = 1, y(b) = 1 2b ; b > 0.
(7.31)
Its exact solution is
y = 1 2x ; (7.32)
by Theorem 6.2 this solution is unique. Note that the general solution of only the ODE (without
boundary conditions) in (7.31) is
y = 1 2x + Ae
30x
+ B e
30x
. (7.33)
MATH 337, by T. Lakoba, University of Vermont 73
Now let us try to use the shooting method to solve the BVP (7.31). Following the lines of
Sec. 7.2, we set up auxiliary IVPs
u
= 30
2
(u 1 + 2x) ,
u(0) = 1, u
(0) = 0 ;
v
= 30
2
v ,
v(0) = 0, v
(0) = 1 ;
(7.34)
and solve them. The exact solutions of (7.34) are:
u = 1 2x +
1
30
e
30x
e
30x
, v =
1
60
e
30x
e
30x
. (7.35)
Then Eq. (7.11) provides the value of the auxiliary parameter
0
:
0
=
(1 2b) (1 2 b +
1
30
(e
30b
e
30b
) )
1
60
(e
30b
e
30b
)
= 2 . (7.36)
That is,
u
(7.35)
+ (2) v
(7.35)
= 1 2x = exact solution , (7.37a)
or, in detail:
1 2x +
1
30
e
30x
e
30x
+ (2)
1
60
e
30x
e
30x
= 1 2x. (7.37b)
Note that each of the terms in curly brackets in (7.37b) is a very large number. For example,
for x = 1.4, the magnitude of the second term is:
1
30
e
301.4
e
301.4
1
30
e
301.4
5.8 10
16
. (7.38)
Now recall that Matlabs round-o error eps = 2.2 10
16
. This means two things:
(i) if for some numbers x and y, one has x y <eps, then Matlab thinks that x y = 0;
(ii) if z is such a large number that z > 1/eps, then Matlab may compute it with an error
that may be of order 1 and even larger.
(In one of the QSAs you will be asked to verify these statements.)
Statement (ii) above along with (7.38) mean
that the expression on the l.h.s. of (7.37b) for
x 1.4 is evaluated by Matlab with an er-
ror of order 1 or larger. That is, the l.h.s. of
(7.37b), as it is evaluated by Matlab, deviates
from the exact solution by as much or more
than the exact solution itself. This quali-
tatively explains the origin of the burst seen
near x = 1.4 in the gure on the right, where
the numerical solution of (7.31) with b = 1.4 is
shown.
0 0.2 0.4 0.6 0.8 1 1.2 1.4
0
10
20
30
40
50
60
x
y
exact
numerical
A reason why this burst is so large almost two orders of magnitude greater than the
exact solution, while the pieces u(x) and v(x) in (7.37) are only a factor of 23 greater than
1/ eps, is not quite clear. Perhaps, one explanation can be that the global errors of the
numerical solutions for u(x) and v(x) are proportional to the large number e
30x
(see Eq. (1.16)
MATH 337, by T. Lakoba, University of Vermont 74
in Lecture 1), and such large errors for u(x) and v(x) do not completely cancel out in (7.37).
Another reason can be that the parameter
0
in (7.36) may be evaluated by Matlab with a
round-o error:
0
= 2 + eps, and then the computed solution is
y = u
(7.35)
+ (2 + eps) v
(7.35)
= 1 2x +
eps
60
e
30x
e
30x
. (7.39)
Again, the third term in that expression may be of order 1 or greater.
The way in which the shooting method is to be modied in order to handle the above problem
is suggested by the gure on the previous page. Namely, one can see that the numerical solution
is quite accurate up to the vicinity of the right end point, where x 1.4 and where the factor
e
30x
multiplied by some small error, overtakes the exact solution. Therefore, if we split the
interval [0, 1.4] into two adjoint subintervals, [0, 0.7] and [0.7, 1.4], and perform shooting on
each of these subintervals, then the corresponding exponential factor, e
300.7
10
9
, will be well
resolved by Matlab: e
300.7
10
9
1 /eps 5 10
15
.
Below we show the implementation details of this approach, known as the multiple shooting
method. (Obviously, the name comes from the fact that the shooting is performed in multiple
(sub)intervals.) These details are worked out for the case of two subintervals, [0, b/2] and
[b/2, b]; a generalization for the case of more subintervals is fairly straightforward.
Consider two sets of auxiliary IVPs that are similar to the IVPs (7.34):
On [0, b/2]:
u
(1)
= 30
2
(u
(1)
1 + 2x) ,
u
(1)
(0) = , u
(1)
(0) = 0 ;
v
(1)
= 30
2
v
(1)
,
v
(1)
(0) = 0, v
(1)
(0) = 1 ;
(7.40)
On [b/2, b]:
u
(2)
= 30
2
(u
(2)
1 + 2x) ,
u
(2)
(b/2) = 0 , u
(2)
(b/2) = 0 ;
v
(2,1)
= 30
2
v
(2,1)
,
v
(2,1)
(b/2) = 1, v
(2,1)
(b/2) = 0 ;
(7.41)
v
(2,2)
= 30
2
v
(2,2)
,
v
(2,2)
(b/2) = 0, v
(2,2)
(b/2) = 1 .
Note 1: The initial condition for u
(1)
at x = 0 is denoted as , even though in the example
considered = 1. This is done to emphasize that the given initial condition is always used for
u
(1)
at the left end point of the original interval.
Note 2: Note that in the 2nd subinterval (and, in general, in the kth subinterval with k 2),
the initial conditions for the u
(k)
must be taken to always be zero. (This is stressed in the
u-system in (7.41) by putting the initial condition for u
(2)
in a box.)
Continuing with solving the IVPs (7.40) and (7.41), we construct solutions
w
(1)
= u
(1)
+
(1)
v
(1)
, w
(2)
= u
(2)
+
(2,1)
v
(2,1)
+
(2,2)
v
(2,2)
, (7.42)
where the numbers
(1)
,
(2,1)
, and
(2,2)
are to be determined. Namely, these three numbers
are determined from three requirements:
w
(1)
(b/2) = w
(2)
(b/2) ,
w
(1)
(b/2) = w
(2)
(b/2) ;
(7.43)
and
w
(2)
(b) = (= 1 2b) ,
(7.44)
MATH 337, by T. Lakoba, University of Vermont 75
Equations (7.43) and (7.44) yield:
w
(1)
(b/2) = w
(2)
(b/2) u
(1)
(b/2) +
(1)
v
(1)
(b/2) = 0 +
(2,1)
1 +
(2,2)
0 ;
w
(1)
(b/2) = w
(2)
(b/2) u
(1)
(b/2) +
(1)
v
(1)
(b/2) = 0 +
(2,1)
0 +
(2,2)
1 ;
w
(2)
(b) = u
(2)
(b) +
(2,1)
v
(2,1)
(b) +
(2,2)
v
(2,2)
(b) = .
(7.45)
In writing out the r.h.s.s of the rst two equations above, we have used the boundary conditions
of the IVP (7.41).
The three equations (7.45) form a linear system for the three unknowns
(1)
,
(2,1)
, and
(2,2)
. (Recall that u
(1)
(b/2) etc. are known from solving the IVPs (7.40) and (7.41).) Thus,
nding the
(1)
,
(2,1)
, and
(2,2)
from (7.45) and substituting them back into (7.42), we obtain
the solution to the original BVP (7.31).
Important note: The multiple shooting method, at least in the above form, can only
be used for linear BVPs, because it is only for them that the linear superposition principle,
allowing us to write
w = u + v ,
can be used.
Further reading on the multiple shooting method can be found in:
P. Deuhard, Recent advances in multiple shooting techniques, in Computation techniques
for ODEs, I. Gladwell and D.K. Sayers, eds. (Academic Press, 1980);
J. Stoer and R. Burlish, Introduction to numerical analysis (Springer Verlag, 1980);
G. Hall and J.M. Watt, Modern numerical methods for ODEs (Clarendon Press, 1976).
7.5 Shooting method for nonlinear BVPs
As has just been noted above, for nonlinear BVPs, the linear superposition of the auxiliary
solutions u and v cannot be used. However, one can still proceed with using the shooting
method by following the general guidelines of Sec. 7.1.
As an example, let us consider the BVP
y
=
y
2
2 + x
,
y(0) = 1, y(2) = 1 .
(7.46)
We again consider the auxiliary IVP
y
1
= y
2
,
y
2
=
y
2
1
2 + x
;
y
1
(0) = 1, y
2
(0) = .
(7.47)
MATH 337, by T. Lakoba, University of Vermont 76
The idea is now to nd the right value(s) of iter-
atively. To motivate the iteration algorithm, let us
actually solve the IVP (7.47) for an (equidistant)
set of s inside some large interval and look at the
result, which is shown in the gure on the right.
(The reason this particular interval of values
is chosen is simply because the instructor knows
what the result should be.) This gure shows that
the boundary condition at the right end point,
y(2)|
as the function of
= 1 , (7.48)
can be considered as a nonlinear algebraic equation
with respect to . Correspondingly, we can employ
well-known methods of solving nonlinear algebraic
equations for solving nonlinear BVPs.
15 10 5 0
5
3
1
1
3
y
(
2
)
prescribed boundary value
Probably the simplest such a method is the secant method. Below we will show how to use
it to nd the values
and
, for which y(2) = 1 (see the gure). Suppose we have tried two
values,
1
and
2
, and found the corresponding values y(2)|
1
and y(2)|
2
. Denote
F(
k
) = y(2)|
k
1 , k = 1, 2 . (7.49)
Thus, our goal is to nd the roots of the equation
F() = 0 . (7.50)
Given the rst two values of F() at =
1,2
, the secant method proceeds as follows:
k+1
=
k
F(
k
)
F(
k
)F(
k1
)
k1
, and then compute F(
k+1
) from (7.49). (7.51)
The iterations are stopped when |F(
k+1
) F(
k
)| becomes less than a prescribed tolerance.
In this manner, one will nd the values
and
+ (2sech
2
x
2
)y = 0, x (, ), y(|x| ) 0 . (7.52)
MATH 337, by T. Lakoba, University of Vermont 77
Here the term 2sech
2
x could be generalized to any
potential V (x) that has one or several humps
in its central region and decays to zero as |x| .
Such a BVP is solvable (i.e., a y(x) can be found
such that y(|x| ) 0) only for some special
values of , called the eigenvalues of this BVP. The
corresponding solution, called an eigenfunction, is
a localized blob, which has some structure in
the region where the potential is signicantly dif-
ferent from zero and which vanishes at the ends of
the innite line. An example of such an eigenfunc-
tion is shown on the right. Note that in general, an
eigenfunction may have a more complicated struc-
ture at the center than just a single hump.
10 0 10
0
x
y
A variant of the shooting method which can nd these eigenvalues is the following. First,
since one cannot literally model the innite line interval (, ), consider the above BVP on
the interval [R, R] for some reasonably large R (say, R = 10). For a given in the BVP,
choose the initial conditions for the shooting as
y(R) = y
0
, y
2
y 0, and hence y
y and y
2
y 0, we have chosen the former, because
it is its solution,
y = e
x
, (7.54)
which agrees with the behavior of the eigenfunction at the left end of the real line (see the
gure above).
The constant y
0
in (7.53) can be taken as
y
0
= e
c R
, (7.55)
where the constant c is of order one. Often one can simply take c = 1.
Now, compute the solution of the IVP consisting of the ODE in (7.52) and the initial
condition (7.53) and record the value y(R). This value can be denoted as G() since it has
been obtained for a particular value of : G() y(R)|
2
u
x
2
+
2
u
y
2
+ k
2
u = 0, (7.56)
where u = 0 along the boundaries of a square with vertices (x, y) = (0, 0), (1, 0), (1, 1), (0, 1),
arises in the mathematical description of oscillations of a square membrane.
One could attempt to obtain a solution of this BVP by shooting from, say, the left side
of this square to the right side. However, not only is this tedious to implement while ac-
counting for all possible combinations of u/x along the side (x = 0, 0 y 1), but
also results of such shooting will be dominated by numerical error and will have nothing in
common with the true solution. The reason is that any IVP for certain two-dimensional equa-
tions, of which (7.56) is a particular case, are ill-posed. We will not go further into this
issue
18
since it would substantially rely on the material studied in a course on partial dif-
ferential equations. What is important to remember out of this brief discussion is that the
shooting method can be used only for one-dimensional BVPs.
In the next lecture we will introduce alternative methods that can be used to solve BVPs
both in one and many dimensions. However, we will only consider their applications in one
dimension.
7.7 Questions for self-assessment
1. Explain the basic idea behind the shooting method (Sec. 7.1).
2. Why did we require that Q(x) 0 in (7.4)?
3. Verify (7.8).
4. Suppose that Q(x) > 0, and we have found that v(b) = 0, as in (7.12). Does this mean
only that the BVP (7.4) will have no solutions, or are there other possibilities?
5. Let Q(x) > 0, as in the previous question, but now we have found that v(b) = 0. What
possibilities for the number of solutions to the BVP do we have?
6. Verify (7.15) and (7.16).
7. Verify (7.20).
8. Verify (7.26).
9. Suppose you need to solve a 5th-order linear BVP. How many auxiliary systems do you
need to consider? How many parameters (analogues of ) do you need to introduce and
then solve for?
18
We will, however, arrive at the same conclusion, but from another view point, in Lecture 11.
MATH 337, by T. Lakoba, University of Vermont 79
10. What allows us to say that by Theorem 6.2 the solution (7.32) is unique?
11. Verify (7.36) and (7.37).
12. Verify statements (i) and (ii) found below Eq. (7.38). Specically, do the following.
(i) Enter in Matlab an expression 2+k*eps where k is some number. Observe how
Matlabs output changes as k increases from being less than 1 to being greater than 1.
(ii) Enter into Matlab an expression 2.5/eps - (2.5/eps + 1) and note the result.
Vary the coecient 2.5 (simultaneously in both terms) and, separately, the coecient 1
and observe what happens.
13. What is a likely cause of the large deviation of the numerical solution from the exact one
in the gure found below Eq. (7.38)?
14. Describe the key idea behind the multiple shooting method.
15. Suppose we use 3 subintervals for multiple shooting. How many parameters analogous to
(1)
,
(2,1)
, and
(2,2)
will we need? What are the meanings of the conditions from which
these parameters can be determined?
16. Verify that the r.h.s.es in (7.45) are correct.
17. Describe the key idea behind the shooting method for nonlinear BVPs.
18. For a general nonlinear BVP, can one tell how many solutions one will nd?