正在加载图片...
17.1 The Shooting Method 757 17.1 The Shooting Method In this section we discuss"pure"shooting,where the integration proceeds from I to 2,and we try to match boundary conditions at the end of the integration.In the next section,we describe shooting to an intermediate fitting point,where the solution to the equations and boundary conditions is found by launching "shots" from both sides of the interval and trying to match continuity conditions at some intermediate point. Our implementation of the shooting method exactly implements multidimen- sional,globally convergent Newton-Raphson(89.7).It seeks to zero n2 functions 81 of n2 variables.The functions are obtained by integrating N differential equations from to x2.Let us see how this works: At the starting point 1 there are N starting values yi to be specified,but 、 subject to n conditions.Therefore there are n2=N-n1 freely specifiable starting values.Let us imagine that these freely specifable values are the components of a vector V that lives in a vector space of dimension n2.Then you,the user,knowing the functional form of the boundary conditions(17.0.2),can write a function that generates a complete set of N starting values y,satisfying the boundary conditions at 1,from an arbitrary vector value of V in which there are no restrictions on the n2 component values.In other words,(17.0.2)converts to a prescription (c1)=班(1;,,V2)i=1,,N (17.1.1) 经6 Below,the function that implements(17.1.1)will be called load. Notice that the components of V might be exactly the values of certain"free" b云P components of y,with the other components of y determined by the boundary 61 conditions.Alternatively,the components of V might parametrize the solutions that satisfy the starting boundary conditions in some other convenient way.Boundary conditions often impose algebraic relations among the yi,rather than specific values for each of them.Using some auxiliary set of parameters often makes it easier to "solve"the boundary relations for a consistent set of yi's.It makes no difference which way you go,as long as your vector space of V's generates(through 17.1.1) Numerica 10621 all allowed starting vectors y Given a particular V,a particular y()is thus generated.It can then be turned 431 into a y(2)by integrating the ODEs to x2 as an initial value problem(e.g,using Recipes Chapter 16's odeint).Now,at x2,let us define a discrepancy vector F,also of dimension n2,whose components measure how far we are from satisfying the n2 腿 boundary conditions at 2(17.0.3).Simplest of all is just to use the right-hand North sides of(17.0.3), f=B2k(c2,y)k=1,,n2 (17.1.2) As in the case of V,however,you can use any other convenient parametrization, as long as your space of F's spans the space of possible discrepancies from the desired boundary conditions,with all components of F equal to zero if and only if the boundary conditions at x2 are satisfied.Below,you will be asked to supply a user-written function score which uses(17.0.3)to convert an N-vector of ending values y(2)into an n2-vector of discrepancies F.17.1 The Shooting Method 757 Permission is granted for internet users to make one paper copy for their own personal use. Further reproduction, or any copyin Copyright (C) 1988-1992 by Cambridge University Press. Programs Copyright (C) 1988-1992 by Numerical Recipes Software. Sample page from NUMERICAL RECIPES IN C: THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521-43108-5) g of machine￾readable files (including this one) to any server computer, is strictly prohibited. To order Numerical Recipes books or CDROMs, visit website http://www.nr.com or call 1-800-872-7423 (North America only), or send email to directcustserv@cambridge.org (outside North America). 17.1 The Shooting Method In this section we discuss “pure” shooting, where the integration proceeds from x1 to x2, and we try to match boundary conditions at the end of the integration. In the next section, we describe shooting to an intermediate fitting point, where the solution to the equations and boundary conditions is found by launching “shots” from both sides of the interval and trying to match continuity conditions at some intermediate point. Our implementation of the shooting method exactly implements multidimen￾sional, globally convergent Newton-Raphson (§9.7). It seeks to zero n 2 functions of n2 variables. The functions are obtained by integrating N differential equations from x1 to x2. Let us see how this works: At the starting point x1 there are N starting values yi to be specified, but subject to n1 conditions. Therefore there are n2 = N − n1 freely specifiable starting values. Let us imagine that these freely specifiable values are the components of a vector V that lives in a vector space of dimension n2. Then you, the user, knowing the functional form of the boundary conditions (17.0.2), can write a function that generates a complete set of N starting values y, satisfying the boundary conditions at x1, from an arbitrary vector value of V in which there are no restrictions on the n 2 component values. In other words, (17.0.2) converts to a prescription yi(x1) = yi(x1; V1,...,Vn2 ) i = 1,...,N (17.1.1) Below, the function that implements (17.1.1) will be called load. Notice that the components of V might be exactly the values of certain “free” components of y, with the other components of y determined by the boundary conditions. Alternatively, the components of V might parametrize the solutions that satisfy the starting boundary conditions in some other convenient way. Boundary conditions often impose algebraic relations among the y i, rather than specific values for each of them. Using some auxiliary set of parameters often makes it easier to “solve” the boundary relations for a consistent set of yi’s. It makes no difference which way you go, as long as your vector space of V’s generates (through 17.1.1) all allowed starting vectors y. Given a particular V, a particular y(x1) is thus generated. It can then be turned into a y(x2) by integrating the ODEs to x2 as an initial value problem (e.g., using Chapter 16’s odeint). Now, at x2, let us define a discrepancy vector F, also of dimension n2, whose components measure how far we are from satisfying the n2 boundary conditions at x2 (17.0.3). Simplest of all is just to use the right-hand sides of (17.0.3), Fk = B2k(x2, y) k = 1,...,n2 (17.1.2) As in the case of V, however, you can use any other convenient parametrization, as long as your space of F’s spans the space of possible discrepancies from the desired boundary conditions, with all components of F equal to zero if and only if the boundary conditions at x2 are satisfied. Below, you will be asked to supply a user-written function score which uses (17.0.3) to convert an N-vector of ending values y(x2) into an n2-vector of discrepancies F
<<向上翻页
©2008-现在 cucdc.com 高等教育资讯网 版权所有