# Spurious Error Messages from NDSolve when Using WhenEvent with Time Delays

Bug introduced between versions 10.1 and 10.4, and resolved in 11.3.

Using either 11.2 or 10.4 on Windows 10 (64 bit), I am unable to reproduce the answer by March to question 99576. Specifically,

timeLimit = 10;
z[t_] = Piecewise[{{1, t <= 2}, {3/2, 2 < t <= 5}}, 2];
NDSolve[{x'[t] == 1/1.5 t, WhenEvent[x[t] == z[t], a[t] -> t],
WhenEvent[t == a[t] + 1, {x[t] -> 0, a[t] -> 0}],
a[t /; t <= 0] == timeLimit, x[t /; t <= 0] == 0},
{x[t], a[t]}, {t, 0, timeLimit}, DiscreteVariables -> {a}];


NDSolve::overdet: There are fewer dependent variables, {x[t],a[t]}, than equations, so the system is overdetermined. >>

Is this a bug? Is there a work-around?

Work-Around

Szabolcs provides a work-around in a comment below, "change a[t /; t <= 0] to a and the same for x". It also works for the problem I originally set out to solve, a delay differential equation, but only because my initial conditions for t <= 0 are constant. Even then, Mathematica 11.2 returns the warning message

NDSolve::ihist : Conditions given at t = 0 will be interpreted as initial history functions for t /; t <= 0.

• I face the same issue on V11.0.1 for Microsoft Windows 7 (32-bit). – zhk Oct 16 '17 at 2:07
• You can change a[t /; t <= 0]  to a and the same for x. The conditional notation does not seem to be necessary here. That said, I would report it. – Szabolcs Oct 16 '17 at 13:13
• @Szabolcs Your solution works, even though the real problem I am trying to solve, a delay differential equation, throws the warning message NDSolveValue::ihist : Conditions given at Notebook$$17150701t = 0 will be interpreted as initial history functions for Notebook$$17$150701t/;Notebook$$17$150701t<=0.` before giving the desired answer. I shall report the problem. Many thanks. – bbgodfrey Oct 16 '17 at 14:02