I thought this was described in some NDSolve
tutorial, but I can't find it. It is mentioned in Only final result from NDSolve, which @andre314 linked in a comment.
The call
NDSolve`ProcessEquations[{y’[x] == y[x], y[a] == 1}, y, {x, b, c}]
with an initial condition at x == a
and interval b <= x <= c
will save only the solution between x == b
and x == c
. The end points b
and c
may be the same, in which case only the solution at x == b
will be saved.
Since I couldn't find documentation, I tested it empirically (see below). With a call of the form
NDSolve`ProcessEquations[ivp, y, {x, x1, x1}]
the user is responsible for storing solution data after each call to NDSolve`Iterate[]
. The data will be discarded with the next call that advances the integration time front.
Appendix: Empirical evidence
First call: save the whole solution.
Quit[]
Block[{n = 30},
char = Times @@ Table[(m^2 + k), {k, 1, n}]; {state} =
NDSolve`ProcessEquations[{CoefficientList[char, m] .
Table[Derivative[k][y][x], {k, 0, 2 n}] == 0,
Table[Derivative[k][y][0] == 1, {k, 0, 2 n - 1}]}, y, {x, 0, 300},
MaxSteps -> 10^5]
]
NDSolve`Iterate[state, 0.01] (* initialize the iteration loop *)
mu = MaxMemoryUsed[];
NDSolve`Iterate[state, 300]
MaxMemoryUsed[] - mu
(* 13558848 *)
Second call: save only the endpoint.
Quit[]
Block[{n = 30},
char = Times @@ Table[(m^2 + k), {k, 1, n}]; {state} =
NDSolve`ProcessEquations[{CoefficientList[char, m] .
Table[Derivative[k][y][x], {k, 0, 2 n}] == 0,
Table[Derivative[k][y][0] == 1, {k, 0, 2 n - 1}]},
y, {x, 300, 300}, MaxSteps -> 10^5]
]
NDSolve`Iterate[state, 0.01](* initialize the iteration loop *)
mu = MaxMemoryUsed[];
NDSolve`Iterate[state, 300]
MaxMemoryUsed[] - mu
(* 12432 *)
NDSolve`ProcessEquations[{y’[x]==y[x],y[0]==1`, y, {x, 1, 2}]
will save only the solution betweenx==1
andx==2
, I think. $\endgroup$