Suppose I want to solve the following equation.
NDSolve[{y''[x] + x^2*y[x] == 0, y[0] == 1, y'[0] == 1},
y[x], {x, 0, 10}]
I want to monitor the stepsize $\Delta x$ Mathematica is using at different x positions to solve this equation in whatever method it is using, be it Runge Kutta or BDF. How to monitor the timestep?
sol = NDSolve[eqns, y (* not y[x]!!! *), {x, 0, 10}]; steps = y["Grid"] /. First[sol] // Flatten; stepsizes = Differences[steps];– Michael E2 Mar 28 '21 at 16:40Monitor, that I use frequently:PrintTemporary@Dynamic@{Clock[Infinity], currenttime}; NDSolve[..., {x, 0, 10}, StepMonitor :> (currenttime = x)], although the OP's example will finish too quickly for this to be useful. – Michael E2 Mar 28 '21 at 17:17StepMonitor :> (currenttime = {x, x - First[#]} &@currenttime), which will give the current time and previous step size. – Michael E2 Mar 28 '21 at 18:21