Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

How exactly does the shooting method work?

  1. Dec 6, 2007 #1
    I have an assignment which requires using the shooting method, but the problem is, I've read numerous things on the internet about exactly how the shooting method works, and I still don't understand it. I was hoping that someone would be kind enough to explain to me the fundamentals of how it works.
  2. jcsd
  3. Dec 6, 2007 #2


    User Avatar
    Science Advisor

    First a description of the difference between "initial value" problems and "boundary value" problems. In an initial value problem, you are told the value of the function and enough of its derivatives at some "initial" value of the independent variable. For a second order differential equation that would mean that you are given the value of both y and y' at some specific value of x. As long as the functions in the differential equation are "nice", there exists a unique solution no matter what the initial conditions are.
    For a "boundary value" problem you are given the value of y at more than one value of x. For a second order differential equation, you would be given the y value at two different values of x (the "boundary" of the interval in question). Even for a very simple differential equation, there might not exist a unique solution, or any solution at all for different boundary conditions.
    For example, the differential equation y"+ y= 0 has y= Ccos(x)+ Dsin(x) as "general solution". Given y(0)= A, y'(0)= B, y= Acos(x)+ Dsin(x) is the unique solution. However, y"+ y= 0, with y(0)= 0, [itex]y(\pi)= 0[/itex] has an infinite number of solutions (y= C sin(x) satisfies the differential equation and the boundary conditions for every value of C) while the boundary value problem y"+ y= 0, with y(0)= 0, [itex]y(\pi)= 0[/itex] has NO solution at all.

    Now, for "shooting".

    Imagine setting a rifle on an "aiming block" where you can adjust the angle of fire. An "initial value problem" would be where you are given the initial position (on the aiming block) and given an initial angle, which you can set. You then fire the bullet and wherever the bullet goes, its trajectory is the solution to that "intial value problem".

    A "boundary value problem", however, would correspond to aiming at a specific target. One "boundary" is the position of the rifle on the aiming block and the other is the target. Since the bullet flies in an arc, not a straight line, you cannot just "point" the rifle at the target. Of course, you can set your sights up so that, for that particular distance, aiming the sights at the target makes the bullet hit the target but how do you set the sights correctly?

    You "aim" the gun at the target, fire, and see where the bullet hits. Use that information to correct your aiming slightly (in this case, if the bullet is high, aim slightly lower). Fire again, and again use the information about where the bullet its the target to adjust your sights. (Of course, the target might be beyond the range of the rifle- the boundary value problem might not have a solution. And, in general, there are two different angles at which you could fire and hit the same target- there is no unique solution.)

    The basic idea of the "shooting method" is that you take one of your given "boundary values", y(a) for some a, and add an arbitrarily chosen y'(a) and do any of many numerical integration schemes (4th order Runge-Kutta is most popular) to solve that "initial value problem". You then check to see how close you came to the other "boundary value" (the "target") and use that information to decide how to change y'(a). After altering y'(a), you "shoot again" and see how close that came.
    What you really want to know, I suspect, is that last part- how do you use the information from your first "shot" to correct y'(a)? Unfortunately that depends strongly on the precise differential equation! From the "shooting" analogy, it might seem reasonable that if, after your first "shot", you are too high (y(b) as calculated is larger than the y(b) you want) then you "lower your sights"- choose y'(a) slightly smaller. However, it is easy to make up example differential equations where that would make the next "shot" worse. The best I can suggest for complete generality is that you "shoot" 3 times. First pick an arbitrary (but "reasonable") y'(a), do your numerical integration, and see how far off the target y(b) it is. Reduce y'(a) a little and repeat. Increase y'(a) a little and repeat. Use that information- whether increasing or decreasing y'(a) gets you closer to your "target" to decide how to change y'(a).
    Using that new y'(a), repeat: "shoot" three times, once with that y'(a), once with a little larger, once with y'(a) a little lower and use that information to adjust y'(a) again.
    "Repeat as desired."
  4. Dec 6, 2007 #3
    wow. That was a great post. It makes alot more sense now. (he says that, and then talks a load of crap, lol)
    I have to write a program to do calculate the wavefunction of an electron. so, I understand it in principle, and it makes alot of sense, but now an attempt to put that into mathematical form:

    [tex] y_{n+1} = \int y_n + y'(a)) dy [/tex]

    Where [itex] 0< n < \frac{x_1 - x_0}{a} [/itex], where the x values represent the limits of the range (technically there should be equals signs on those equalities, but I don't know how to put them on). I take a value [itex] y_0 [/itex], and then by using guessed (or rather, estimated) values of y'(a), I have to try and get [itex] y_N [/itex] equal what it should, as defined by the boundary conditions defined in the problems. ([itex] y_N [/itex] is the last value to calculate).

    If that's how it works, It doesn't seem too bad, but have I got the right idea as how it works?
    I've got a feeling that the maths I wrote above isn't right, just because it doesnt make sense dimensionally, nm.
    Last edited: Dec 6, 2007
  5. Jul 17, 2010 #4
    I have to agree with the person who originally asked about the shooting method: great post!

    Could you extend your explaination to direct multiple shooting methods? How does the direct multiple shooting method work?
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook