Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to solve an ODE with NDSolve using the "ExplicitRungeKutta" method. I need to know exactly which time steps NDSolve chooses, i.e., which points in the interval $[tmin, tmax]$ it chooses when it implements the Runge-Kutta method before the interpolation is made). What should I do?

share|improve this question
2  
See NDSolveStateData, in particular the section NDSolve`StateData Properties; also see NDSolveExplicitRungeKutta; other methods can be found in NDSolveOverview. – Michael E2 May 29 '14 at 12:12
2  
NDSolveUtilities can be used for analyzing the solution after the solution has been constructed. – Michael E2 May 29 '14 at 13:13
2  
quick and dirty way: ClearAll[g]; g[x_?NumericQ] := (Sow[x]; Cos[x]); ListPlot@Last@ Last@Reap[NDSolve[{y'[x] == y[x] g[x], y[0] == 1}, y, {x, 0, 30}, Method -> "ExplicitRungeKutta"]] – acl May 29 '14 at 23:09

To take this off the unanswered list:

The steps are the abscissae stored in the interpolating function returned by NDSolve:

ysol = First@
   NDSolve[{y'[x] == y[x] Cos[x + y[x]], y[0] == 1}, y, {x, 0, 10}, 
    Method -> "ExplicitRungeKutta"];

steps = y["Coordinates"] /. ysol // First
(*
  {0., 0.120351, 0.527517, 0.921285, 1.33461, 1.85473, 2.27071, 
   2.75617, 3.20612, 3.69883, 4.24451, 4.86677, 5.51721, 6.0665, 
   6.59295, 7.1106, 7.57393, 8.07059, 8.6011, 9.25316, 9.62658, 10.}
*)
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.