# How can I get the time steps chosen by NDSolve when the Method -> "ExplicitRungeKutta" option is given?

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?

• See NDSolveStateData, in particular the section NDSolveStateData Properties; also see NDSolveExplicitRungeKutta; other methods can be found in NDSolveOverview. May 29 '14 at 12:12
• NDSolveUtilities can be used for analyzing the solution after the solution has been constructed. May 29 '14 at 13:13
• 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 == 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 == 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.}
*)
`