# Backward in time numerical integration with fixed time step

Consider simple use of NDSolve[] function used to solve an ODE backward in time

NDSolve[{x'[t] == x[t], x[0] == 1}, x, {t, -1, 0}]


With default settings one can obtain solution in domain $[-1,0]$. If I would like to use a fixed step integration with a priori choosen step size I would call

NDSolve[{x'[t] == x[t], x[0] == 1}, x, {t, -1, 0},
Method -> {"FixedStep", Method -> Automatic, "StepSize" -> 1/10}]


The above code fails to give a result and complains

NDSolve::sss: Unable to determine a starting step size for the method NDSolveFixedStep. >>

Why is that the "FixedStep" method of NDSolve[] do not support backward in time integration?

• I answered this yesterday... – ciao Sep 9 '15 at 21:12
• @ciao Could you please provide a link to the answer? – mmal Sep 10 '15 at 7:46
• Oh, sorry, It was leg-pulling, as in I answered it before you posted it, as in... backward in time... – ciao Sep 10 '15 at 7:53

Based on the documentation to "FixedStep" Method for NDSolve, I suggest

s = First@NDSolve[{x'[t] == x[t], x[0] == 1}, x, {t, -1, 0},
StartingStepSize -> 1/10, Method -> {"FixedStep", Method -> Automatic}];
Plot[x[t] /. s, {t, -1, -0}, AxesLabel -> {x, t}]


The key change is to use StartingStepSize as an option instead of "StepSize" as a method.

• Yes, I was aware of this solution. But, isn't it a little bit too odd... I mean changing direction of integration shouldn't change the precedence of options? It still doesn't work when one specify both StartingStepSize and StepSize options. – mmal Sep 10 '15 at 19:53
• @mmal. Yes, it is strange. But, there are lots of strange things about Mathematica. – bbgodfrey Sep 10 '15 at 20:18
• @mma It doesn't hurt to report it. Who knows if this can be added to the improvements list... – P. Fonseca Sep 10 '15 at 21:10
• @mmal I agree. Please do report this. – bbgodfrey Sep 10 '15 at 21:30
• @P.Fonseca I think it does not. The purpose of this question was to see if anyone has a working solution, probably someone may know more about the NDSolve` machinery and be able to explain observed behavior... – mmal Sep 11 '15 at 6:55