Initial time as parameter in ParametricNDSolve

Apparently, ParametricNDSolve cannot handle x[t0] or y[t0] when t0 is a parameter. A work-around is to shift time to begin at t0, in which case the code becomes,

sol = ParametricNDSolve[{x'[t] == y[t], 
    y'[t] == x[t] - 1 - ϵ Cos[5 (t + t0)], x[0] == x0, 
    y[0] == y0}, {x, y}, {t, -t0, -t0 + 10}, {t0, x0, y0, ϵ}]

which works fine. This does seem like a Mathematica shortcoming, however.

enter image description here


Given that ParametricNDSolve does not handle this case, one can revert to the old way. Uncomment the memoization if desired; it will speed things up if sol is called multiple times with the same parameters.

Clear[sol];
sol[t0_, x0_, y0_, ϵ_] :=
 (*sol[t0, x0, y0, ϵ] =*)
  NDSolve[{x'[t] == y[t], y'[t] == x[t] - 1 - ϵ Cos[5 t], 
   x[t0] == x0, y[t0] == y0}, {x, y}, {t, 0, 10}]

Here's a different plot to show that the dependence on t and t0 is as desired:

Plot[Evaluate[Table[y[t] /. sol[t0, 0, 1, 0], {t0, -1, 1, .2}]],
 {t, 0, 1}, PlotRange -> All, GridLines -> {None, {1}}]

Mathematica graphics