Returned value when the time specified in SaveAt are finer than dt0
Hi,
Let's say I do something like the following:
vector_field = lambda t, y, args: -y
term = ODETerm(vector_field)
solver = Dopri5()
saveat = SaveAt(ts=[0.001, 0.002])
sol = diffeqsolve(term, solver, t0=0, t1=3, dt0=0.1, y0=1, saveat=saveat,
stepsize_controller=dfx.ConstantStepSize())
Due to the setting y0=1 and stepsize_controller=dfx.ConstantStepSize(), I think the solver will calculate the value of $y\left(t\right)$ at $t = n \times 0.1$ where $n$ is an integer. This does not cover the time points specified in saveat. Yet, I note the solver can still return some values for $t = 0.001$ and $t = 0.002$. Are these return values accurate, or they are some interpolation from the values at $t = n \times 0.1$?
Thanks!
These values are found by interpolation: specifically, by using the values at $t = n \times 0.1$ and all the stages of the Runge-Kutta method used to make the step from $k \times 0.1$ to $(k + 1) \times 0.1$, which also includes the values of the vector field at $t = n \times 0.1$.
If you're curious about the precise details for any particular solver, then the interpolation method is given by solver.interpolation_cls.
As a design point, Diffrax does all of its stepping without looking at the values of SaveAt(ts=...). This is to try and avoid subtle flakiness when your solver might integrate for one value of ts, but explode for another! (And morally speaking, the value of the solution shouldn't change just depending on when you want to look at it!)