# How to shoot backwards using the "Shooting Method"?

This is my first time asking a question on here, and I look forward to and appreciate your help.

I believe I have a simple question. I am reading the documentation for the "shooting method" and trying to understand how to shoot "backward". The documentation is here:

https://reference.wolfram.com/language/tutorial/NDSolveBVP.html

The documentation explains that it can be advantageous to shoot backward (or from somewhere in the middle of the interval). But their example does not make much sense to me. First, they solve the system, but seemingly without calling on the shooting method. Then they solve it using the shooting method, but I don't see how they are shooting backward.

For context, I am trying to solve a differential equation which is singular at x=1 numerically, but most of the solutions lie in a thin strip near x=1. What I want is to start from some value like .9 and check for solutions between (.9,1), but the shooting method actually starts from .9 and then checks everything between (0,.9).

It seems there should be an option to tell the shooting method to "go the other way", but I can't find it in the documentation.

• Will a simple change of variables, e.g. x->-x help? Commented Jun 3, 2022 at 21:34
• Look up "StartingInitialConditions" in the help center (or doc you linked). Commented Jun 3, 2022 at 21:38
• You might get more concrete answers if you include an example problem! Commented Jun 3, 2022 at 22:31
• @mikado: That's a great idea! Unfortunately this will not work for me, though.
– Mark
Commented Jun 13, 2022 at 17:07
• Sorry everyone for the long delay in my response, I never imagined that so many people would reach out to help so quickly. I'm sincerely appreciative.
– Mark
Commented Jun 13, 2022 at 17:15

The "StartingInitialConditions" suboption sets the IC at x == 0.9, and with good values for the IC, a successful integration results:

NDSolve[{y''[x] == 1/Sqrt[1 - x] + y[x]^2, y[0] == 1,
y[1 - 100 $$MachineEpsilon] == 2}, y, {x, 0, 1 - 100$$MachineEpsilon},
Method -> {"Shooting",
"StartingInitialConditions" -> {y[0.9] == 1.8, y'[0.9] == 2}}];
ListLinePlot[y /. %]


The following uses bad starting values for the IC at x == 0.9 and fails to integrate (one of the pitfalls of the shooting method):

NDSolve[{y''[x] == 1/Sqrt[1 - x] + y[x]^2, y[0] == 1,
y[1 - Sqrt@$$MachineEpsilon] == 2}, y, {x, 0, 1 - 100$$MachineEpsilon},
Method -> {"Shooting",
"StartingInitialConditions" -> {y[0.9] == 11.8, y'[0.9] == 2}}]
(* NDSolve::ndsz error and returns input *)


It fails in this case because with a large enough value for y[0.9], a singularity develops in the starting test solution before x reaches 0 and, if very large, before x reaches the upper endpoint. In such a case, the error at the boundary conditions is undefined, and NDSolve does not know how to adjust the initial conditions. It quits and punts the problem back to the user.

• @Mark You're welcome. For complicated requirements, a manual approach using ParametricNDSolve, such as here, might work. You might need to explore how to set up FindRoot in the docs. You can find more examples with this site search: mathematica.stackexchange.com/… Commented Jun 13, 2022 at 17:22