# Intermediate variables in the system of Delay Differential Equations [closed]

Im trying to solve a system of ordinary differential equations with some delay. I defined an intermediate variable in order to organize the system and also avoid that the system compute the same expression several times. Here is an small example of my problem

if i try to solve this system like this

NDSolve[{x'[t] == - y[t - 1] + k[t], y'[t] == -k[t] + x[t - 1],
k[t] == x[t] + y[t], x[t /; t < 0] == 1, y[t /; t < 0] == 0, k[t /; t < 0] == 1},
{x, y, k} , {t, 0, 3}]


it gives this message and also quits the kernel

But if I change k[t] by the value x[t]+y[t] it gives the solution without any problem

NDSolve[{x'[t] == - y[t - 1] + (x[t] + y[t]),
y'[t] == -(x[t] + y[t]) + x[t - 1],
x[t /; t < 0] == 1, y[t /; t < 0] == 0}, {x, y}, {t, 0, 3}]


Does anybody know why is this happening? I would be grateful for your help... Thanks in advance Luis

• Which version are you using? In v9.0.1 NDSolve gives the desired solution in both cases. (Though a warning ivcon generated. ) – xzczd Jan 31 '17 at 3:39
• I'm voting to close this question as off-topic because nobody is able to reproduce the issue mentioned by OP for so long. – xzczd Feb 6 '17 at 8:49
• Are you still waiting for an answer? – zhk Feb 17 '17 at 8:01

One way to do it is to convert the algebraic equation k[t] == x[t] + y[t] to a DE k'[t] == x'[t] + y'[t].

sol = NDSolve[{x'[t] == -y[t - 1] + k[t], x[t /; t <= 0] == 1,
y'[t] == -k[t] + x[t - 1], y[t /; t <= 0] == 0,
k'[t] == x'[t] + y'[t], k[t /; t <= 0] == 1}, {x, y, k}, {t, 0, 3}];
Plot[Evaluate[{x[t], y[t], k[t]} /. sol], {t, 0, 3},PlotStyle -> {Thick}, Frame -> True] Now we will compare the above solution with the one you got from direct substitution of k[t] in the system.

sol1 = NDSolve[{x'[t] == -y[t - 1] + (x[t] + y[t]),
y'[t] == -(x[t] + y[t]) + x[t - 1], x[t /; t < 0] == 1,
y[t /; t < 0] == 0}, {x, y}, {t, 0, 3}]
Show[Plot[Evaluate[{x[t], y[t]} /. sol], {t, 0, 3},
PlotStyle -> {Directive[Red, Thick], Directive[Red, Thick]},
Frame -> True],
Plot[Evaluate[{x[t], y[t]} /. sol1], {t, 0, 3},
PlotStyle -> {Directive[Green, Dashed], Directive[Green, Dashed]},
Frame -> True]] • Im using the version 11. In this version it does not give the solution in the second case, which is something rare that i can not understand. Thank you very much for your solution – Luis Jan 31 '17 at 19:07
• @Luis, I am using the same MMA. Can you explain more? – zhk Jan 31 '17 at 19:10
• @luis v11.0 or v11.0.1? And what's your OS? – xzczd Feb 3 '17 at 12:19