Вы находитесь на странице: 1из 16

Shooting Method

Kamil Yucel 200322050

Department of Mathematics and Computer Science Faculty of Art and Science Cankaya University January 21, 2010

Contents
1 Introduction 2 Preliminaries 3 Linear Shooting 3.1 Simple Boundary Conditions . . . . . . . . . . . . . . . . . . . 3.2 General Boundary Condition at x = b . . . . . . . . . . . . . . 3.3 General Seperated Boundary Conditions . . . . . . . . . . . . 3 4 5 5 8 9

4 Nonlinear Shooting 9 4.1 Nonlinear Shooting Based on the Secant Method . . . . . . . . 10 4.2 Nonlinear Shooting using Newtons Method . . . . . . . . . . 11 5 Applications 6 Conclusion 13 14

Introduction

In mathematics, in the eld of dierential equations, an initial value problem (IVP) is an ordinary dierential equation (ode), which frequently occurs in mathematical models that arise in many branches of science, engineering and economics, together with specied value, called the initial condition, of the unknown function at a given point in the domain of the solution. y = f (x, y) y(x0 ) = y0 (1.1) (1.2)

There is also another case that we consider an ordinary dierential equation (ODE), we require the solution on an interval [a,b], and some conditions are given at a, and the rest at b, although more complicated situations are possible, involving three or more points. We call this a boundary value problem (BVP). y + r(x)y = f (x), a < x < b with the boundary conditions y(a) = A, y(b) = B (1.4) (1.3)

For analytical solutions of IVPs and BVPs, there exist many dierent methods in literature. Numerical solutions of such kind of problems is a subject which can be treated seperately. There are also several methods derived until now. The numerical methods for the solution of IVPs of ODEs are classied in two major groups: the one-step methods and multi-step methods. The one-step methods are as follows: Taylor methods, Eulers Method, Runge-Kutta Methods. The linear multistep methods are implicit Euler method, Trapezium rule method, Adams - Bashforth method, Adams - Moulton method, Predictor - Corrector methods. Similarly, for the numerical study of boundary value problems there exists some methods like, Shooting method for linear and nonlinear BVP, Finite-Dierence method for linear and nonlinear BVP. [??] In this project, our aim is to study the Shooting Method for the numerical solutions of second order BVPs both for linear and nonlinear case. 3

The algorithm of these methods are presented to see how the method works. Some examples are given to show the performance and advantages. The plan of this project is as follows: In the rst section we will give a denition of shooting method and where we use it and for which kind of problems it is used. In the second section we give an explanation to Linear Shooting. The third section is about Nonlinear Shooting. Before the conclusion part we will solve some examples in the Application section with using our method.

Preliminaries

Ordinary dierential equations are given either with initial conditions or with boundary conditions. The shooting method uses the same methods that were used in solving initial value problems. This is done by assuming initial values that would have been given if the ordinary dierential equation were an initial value problem. The boundary value obtained is then compared with the actual boundary value. Using trial and error or some scientic approach, one tries to get as close to the boundary value as possible. Mainly, the central idea of the method is to replace the boundary value problem under consideration by an initial value problem of the form y + r(x)y = f (x), a < x < b y(a) = A, y (a) = t (2.1) (2.2)

where t is to be chosen in such a way that y(b) = B. This can be thought of as a problem of trying to determine the angle of inclination tan1 t of a loaded gun, so that, when shot from height B at the point x = a, the bullet hits the target placed at height B at the point x = b. Hence the name, shooting method. Once the boundary value problem has been transformed into such an equivalent initial value problem, any of the methods for the numerical solution of initial value problems can be applied to nd a numerical solution. The following theorem gives general conditions that ensure that the solution to a second-order boundary value problem exists and is unique.

Theorem 2.1 Suppose the function f in the boundary value problem y = f (x, y, y ), a x b, y(a) = A, y(b) = B, is continuous on the set D = {(x, y, y ) | a x b, < y < , < y < } and that f /y and f /y are also continuous on D. If (i) f /y(x, y, y ) > 0 for all (x, y, y ) D, and (ii) A constant M exists, with |f /y(x, y, y )| M, f or all (x, y, y ) D. (2.5) (2.4) (2.3)

then the boundary value problem has a unique solution. proof: See the reference 

Linear Shooting

A linear two - point boundary value problem can be solved by forming a linear combination of the solutions to two initial value problems. The form of the IVP depends on the form of the boundary conditions. We begin with the simplest case, Dirichlet boundary conditions, in which the value of the function is given at each end of the interval. We then consider some more general boundary conditions. 

3.1

Simple Boundary Conditions

Suppose the two - point boundary value problem is linear, i.e., of the form y = p(x)y + q(x)y + r(x), a x b, (3.1)

with boundary conditions y(a) = A, y(b) = B. The approach is to solve the two IVPs u = p(x)u + q(x)u + r(x), 5 u(a) = A, u (a) = 0, (3.2)

v = p(x)v + q(x)v,

v(a) = 0,

v(a) = 1.

(3.3)

If v(b) = 0, the solution of the original two - point BVP is given by y(x) = u(x) + B u(b) v(x) v(b) (3.4)

This solution is based on the standard technique of solving a linear ODE by nding a general solution of the homogenous equation (expressed as the ODE for v) and a particular solution of the nonhomogeneous equation (expressed as the ODE for u). The arbitrary constant C that would appear in the solution y(x) = u(x) + C v(x) is found from the requirement that y(b) = u(b) + Cv(b) = B, which yields C = Bu(b) . v(b) In order to approximate the solution of the linear ODE - BVP y = p(x)y + q(x)y + r(x), with boundary conditions y(a) = A, y(b) = B, using the linear shooting method, we must convert the problem to a system of four rst - order ODE - IVP, which we write as z = f (x, z). The variables z1 and z2 are u and u , u respectively, where u satises the ODE - IVP u = p(x)u + q(x)u + r(x), with initial conditions u(a) = A, u (a) = 0. The variables z3 and z4 are v and v , respectively, where v satises the ODE IVP v = p(x)v + q(x)v, with initial conditions v(a) = 0, v (a) = 1. Dene the variables, z1 , z2 , z3 and z4 z1 = u z2 = u z3 = v z4 = v Dene the ODE z 1 = z2 z 2 = p(x)z2 + q(x)z1 + r(x) z 3 = z4 z 4 = p(x)z4 + q(x)z3 Dene the initial conditions z1 (a) = A z2 (a) = 0 z3 (a) = 0 z4 (a) = 0 The original problem has been converted into the appropriate system of the rst - order ODE - IVP as described above. The components of the solutions are shown as z1 , z2 , z3 , and z4 , although a 2-dimensional array could also be used for z if desired.

Example 3.1 A simple Linear Shooting Problem Consider the ODE

y =

x2

2x 2 y 2 y + x2 + 1, +1 x +1

u(0) = 2,

u (0) = 0.

(3.5)

with boundary conditions y(0) = 2, y(1) = 5/3 To use the shooting method for this problem, we must solve the IVP 2 2x v 2 v, v(0) = 0, v (0) = 1. (3.6) x2+1 x +1 Letting z1 = u, z2 = u , z3 = v, z4 = v , the second - order IVP become u =

z 1 = z2 z2= 2x 2 z2 2 z1 + x2 + 1 x2 + 1 x +1 z 3 = z4 z4=

(3.7) (3.8) (3.9)

2 2x z4 2 z3 (3.10) +1 x +1 And for computer algorithm intial conditions for system z0 = [A001] Initialize parameters a=0 b=1 h = (b a)/n Dene grid points for i = 1 to n x(i) = a + h i end Solve the ODE - IVP system, using any appropriate method Use solution of system to construct solution to BVP for i = 1 to n x2 7

y(i) = z1 (i) + (B z1 (n) z3 (i)/z3 (n)) end For reference, we note that the general solution of the ODE is

(3.11)

3.2

y = p(x)y + q(x)y + r(x);

(3.12)

has boundary conditions consisting of the value of y given at x = a, but the condition at x = b involves a linear combination of y(b) and y (b):

y(a) = A;

y (b) + cy(b) = B

(3.13)

u = p(x)u + q(x)u + r(x), v = p(x)v + q(x)v,

u(a) = A,

u (a) = 0,

(3.14) (3.15)

v(a) = 0,

v (a) = 1.

The linear combination, y = u + dv, satises the condition at x = a, since y(a) = A. We now need to nd d (if possible) so that y satises

y (b) + cy(b) = B If v (b) + cv(b) = 0, there is a unique solution, given by B u (b) cu(b) v(x) v (b) + cv(b)

(3.16)

y(x) = u(x) +

(3.17)

3.3

Suppose that the linear ODE

y = p(x)y + q(x)y + r(x) has mixed boundary conditions at both x = a and x = b; i.e.,

(3.18)

y (a) + c1 y(a) = A,

y (b) + c2 y(b) = B,

(3.19)

As in the previous discussion, the approach is to solve two IVPs, however, the appropriate forms are now u = p(x)u + q(x)u + r(x), v = p(x)v + q(x)v, u(a) = 0, u (a) = A, (3.20) (3.21)

v(a) = 1,

v (a) = c1 .

The linear combination y = u + dv satises y (a) + c1 y(a) = A; we need to nd d (if possible) such that y satises y (b) + c2 y(b) = B. If v (b) + c2 v(b) = 0, there is a unique solution, given by B u (b) c2 u(b) v(x) v (b) + c2 v(b)

y(x) = u(x) +

(3.22)

Nonlinear Shooting

We now consider the shooting method for nonlinear problems of the form y = f (x, y, y ) on the interval [a, b]. We assumw that y(a) is given and that some condition on the solution is also given at x = b. The idea is the same as for linear problems, namely, to solve the appropriate initial - value problems and use the results to nd to nd a solution to the nonlinear problem. However, for a nonlinear BVP, we have an iterative procedure rather than a simple formula for combining the solutions of two IVPs. In both the linear and the nonlinear case, we need to nd a zero of the function representing the error-that is, the amount by which the solution to the IVP fails to satisfy 9

the boundary condition at x = b. We assume the continuity of f , fx and fy on an appropriate domain, to ensure that the initial - value problems have unique solutions. We begin by solving the initial value problem

u = f (x, u, u ),

u(a) = A,

u (a) = t,

(4.1)

for some particular value of t. We then nd the error associated with this solution; that is, we evaluate the boundary condition at x = b using u(b) and u (b). Unless it happens that u(x) satises the boundary condition at x = b, we take a diferent initial value for u (a) and solve the resulting IVP. Thus, the error (the amount by which our shot misses its mark) is a function of our choice for the initial slope. We denote this function as m(t). There are two dierent approaches that we use. The rst approach we consider uses the secant method to nd the zero of the error function. This allows us to treat a fairly general boundary condition at x = b. The second approach is based on Newtons method.

4.1

Nonlinear Shooting Based on the Secant Method

To solve a nonlinear BVP of the form y = f (x, y, y ), y(a) = A, h(y(b), y (b)) = 0, (4.2)

we may use an iterative process based on the secant method. We need to nd a value of t, the initial slope, so that solving eq. (4.1) gives a solution that is within a specied tolerance of the boundary condition at x = b. We begin by solving the equation with u (a) = t(1) = 0; the corresponding error is m(1). Unless the absolute value of m(1) is less than the tolerance, we continue by solving eq. (4.1) with u (a) = t(2) = 1. If this solution does not happen to stisfy the boundary condition (at x = b) either, we continue by updating our initial slopes according to the secant rule (until our stopping condition is satised), i.e., t(i 1) t(i 2) m(i 1). m(i 1) m(i 2) 10

t(i) = t(i 1)

(4.3)

4.2

Nonlinear Shooting using Newtons Method

We next illustrate how Newtons method can be used to nd the value of y (a) = t in the initial value problem for nonlinear shooting. We consider the following nonlinear BVP with simple boundary conditions at x = a and x = b:

y = f (x, y, y ),

y(a) = A,

y(b) = B,

(4.4)

We begin by solving the initial - value problem

u = f (x, y, u ),

u(a) = A,

u (a) = t,

(4.5)

The error in this solution is the amount by which y(b) misses the desired value, B. For dierent choices of t, we get dierent errors, so we dene

m(t) = u((b, t) B.

(4.6)

We need to nd t such that m(t) = 0 (or m(t) is as close to zero as we wish to continue the process). In the previous section, we founda a sequence of t using linear interpolation between the two previous solution; in order to use Newtons method, we need to have the derivative of the function whose zeor is required, namely, m(t). Although we do not have an explicit formula for m(t), we can construct an additional dierential equation whose solution allows us to update t at each iteration. 

u = f (x, u, u ),

u(a) = A,

(4.7) (4.8)

v = vfu (x, u, u ) + v fu (x, u, u ),

Example 4.1 Nonlinear Shooting with Newtons Method To illustrate the use of nonlinear shooting using Newtons method, consider the ODE - BVP

11

[y ]2 y = , y

y(0) = 1,

y(1) = 2,

(4.9)

The initial value problem consist of two second - order ODEs; the rst corresponds to the original problem, but with the boundary condition replaced by an initial condition on the rst derivative, u (0) = tk . The second ODE is an auxiliary equation that allows us to update the value of the parameter tk . The rst ODE is u = [u ]2 .u1 ,

u(0) = 1,

u (0) = tk.

(4.10)

(4.11) (4.12)

v = v[u ]2 .u2 v 2[u ]u1 ,

v(0) = 0,

v (0) = 1.

(4.13)

Writing this as a system of four rst - order ODEs, we dene the components of our unknown function z as follows:

z1 = u, The ODEs are

z2 = u ,

z3 = v,

z4 = v .

(4.14)

z1 = z2 z3 = z4

z2 =

2 z2 z1

(4.15) (4.16)

z4 = z3 (

z2 2 2z4 z2 ) z1 z1

12

Applications

Example 5.1 Electrostatic Potential Between Two Spheres The electrostatic potential between two concentric spheres can be represented by the secon - order ODE 2 y. (5.1) x If we assume that the radius of the inner sphere is 1 and its potential is 10, while the radius of the outer sphereis 2 and its potential is 0, then the boundary conditions are y =

y(1) = 10;

y(2) = 0.

(5.2)

This equation can be converted to the pair of initial - value problems 2 u, x

u = v =

u(1) = 10,

u (1) = 0,

(5.3)

2 v , v(1) = 0, v (1) = 1. (5.4) x which in turn becomes a system of four rst - order initial value problems by dening the variables z1 , ....z4 as z1 = u, z2 = u , z3 = v, z4 = v . The dierential equation become 2 z2 , x 2 z4 x

z1 = z2 , with initial condition

z2 =

z3 = z4 ,

z4 =

(5.5)

z1 (1) = 10,

z2 (1) = 0,

z3 (1) = 0,

z4 (1) = 1

(5.6)

The solution of the original ODE is the linear combination of the solutions u and v, or, in terms of our system,

13

y(x) = z1 (x) +

B z1 (b) z3 (x). z3 (b)

(5.7)

14

Conclusion

In this project, shooting method is presented for the numerical solution of second - order BVPs. Both linear and nonlinear versions of shooting method are described and the procedure of these methods are presented to show they are applied on a given problem and their performance. Some representative examples are presented. In the last part of this work, a LNEAR BVP is solved by using linear second - order shooting method as an application.

15

References
 B. Rai, D. P. Choudhury, H.I. Freedman, A Course in Ordinary Dierential Equations, Alpha Service, (2002)  Richard L. Burden, J. Douglas Faires, Numerical Analysis, Brooks, (2004)  Endre Suli, david Meyers, An Introduction to Numerical Analysis, Cambridge, (2003)  Lauren V. Fausett, Numerical Methods, Prentice Hall, (2003)

16