Delay Differential Equations
A delay differential equation is a differential equation where the time derivatives at the current time depend on the solution and possibly its derivatives at previous times:
Instead of a simple initial condition, an initial history function
(t) needs to be specified. The quantities
i ≥ 0, i=1, ..., n and
i ≥ 0, i=1, ..., k are called the delays or time lags. The delays may be constants, functions
( t) and
( t) of
t (time dependent delays), or functions
(t, X (t)) and
( t, X (t)) (state dependent delays). Delay equations with delays

of the derivatives are referred to as neutral delay differential equations (NDDEs).
The equation processing code in
NDSolve has been designed so that you can input a delay differential equation in essentially mathematical notation.
x[t- ] | dependent variable x with delay  |
x[t /; t≤t0]= | specification of initial history function as expression for t less than t0 |
Inputting delays and initial history.
Currently, the implementation for DDEs in
NDSolve only supports constant delays.
Solve a second order delay differential equation.
| Out[1]= |  |
|
Plot the solution and its first two derivatives.
| Out[2]= |  |
|
For simplicity, this documentation is written assuming that integration always proceeds from smaller to larger
t. However,
NDSolve supports integration in the other direction if the initial history function is given for value above
t0 and the delays are negative.
Solve a second order delay differential equation in the direction of negative t.
| Out[3]= |  |
|
Comparison and contrast with ODEs
While DDEs look a lot like ODEs the theory for them is quite a bit more complicated and there are some surprising differences with ODEs. This section will show a few examples of the differences.
Look at the solutions of x (t)=x (t-1) (x (t)-1) for different initial history functions.
| Out[47]= |  |
|
As long as the initial function satisfies
(0)=1, the solution for
t>0 is always 1.
[Z06] With ODEs, you could always integrate backwards in time from a solution to obtain the initial condition.
Investigate at the solutions of x (t)=a x (t) (1-x (t-1)) for different values of the parameter a.
| Out[1]= |  |
|
For

, the solutions are monotonic, for

the solutions oscillate. and for

the solutions approach a limit cycle. Of course, for the scalar ODE, solutions are monotonic independent of
a.
Solve the Ikeda delay differential equation, x (t) sin (x (t-2 )) for two nearby constant initial functions. |
| Out[90]= |  |
|
This simple scalar delay differential equation has chaotic solutions and the motion shown above looks very much like Brownian motion. [
S07] As the delay

is increased beyond
=
/2 a limit cycle appears, followed eventually by a period doubling cascade leading to chaos before
=5.
Compare solutions for  =4.9, 5.0, and 5.1
| Out[104]= |  |
|
Stability is much more complicated for delay equations as well. It is well known that the linear ODE test equation
x
(t)=
x (t) has asymptotically stable solutions if
Re (
)<0 and is unstable if
Re (
)>0.
The closest corresponding DDE is
x
(t)=
x (t)+
x (t-1). Even if you consider just real

and

the situation is no longer so clear cut. Shown below are some plots of solutions indicating this.
The solution is stable with  and =-1
| Out[110]= |  |
|
The solution is unstable with  and =4
| Out[111]= |  |
|
So the solution can be stable with
>0 and unstable with
<0 depending on the value of

. A
Manipulate is set up below so that you can investigate the

-

plane.
Investigate by varying  and 
| Out[113]= |  |
|
Propagation and smoothing of discontinuities
The way discontinuities are propagated by the delays is an important feature of DDEs and has a profound effect on numerical methods for solving them.
Solve x (t) x (t-1) with x (t)=1 for t≤0.
| Out[3]= |  |
| Out[4]= |  |
|
In the example above,
x (t) is continuous, but there is a jump discontinuity in
x
(t) at
t=0 since approaching from the left the value is 0, given by the derivative of the initial history function
x
(t)=
(t)=0 while approaching from the right the value is given by the DDE, giving
x
(t)=x (t-1)=
(t-1)=1.
Near t=1, we have by the continuity of x at 0

and so
x
(t)is continuous at
t=1.
Differentiating the equation, we can conclude that
(x
)
(t)
x
(t-1) so
(x
)
(t) has a jump discontinuity at
t=1. Using essentially the same argument as above, we can conclude that at
t=2 the second derivative is continuous.
Similarly,
x (k) (t)
is continuous at
t=k
or, in other words, at
t=k
,
x (t)
is k times differentiable. This is referred to as smoothing and holds generally for non-neutral delay equations. In some cases the smoothing can be faster than one order per interval.[
Z06
]
For neutral delay equations the situation is quite different.
Solve x (t) x' (t-1) with x (t)=-t for t≤0.
| Out[12]= |  |
| Out[11]= |  |
|
It is easy to see that the solution is piecewise with x[t] continuous. However,
which has a discontinuity at every non negative integer.
In general, there is no smoothing of discontinuities for neutral DDEs.
The propagation of discontinuities is very important from the standpoint of numerical solvers. If the possible discontinuity points are ignored, then the order of the solver will be reduced. If a discontinuity point is known a more accurate solution can be found by integrating just up to the discontinuity point and then restarting the method just past the point with the new function values. This way, the integration method is used on smooth parts of the solution leading to better accuracy and fewer rejected steps. From any given discontinuity points, future discontinuity points can be determined from the delays and detected by treating them as events to be located.
When there are multiple delays, the propagation of discontinuities can become quite complicated.
Solve a neutral delay differential equation with two delays.
| Out[109]= |  |
|
| Out[110]= |  |
|
It is clear from the plot that there is a discontinuity at each non negative integer as would be expected from the neutral delay
=1. However, looking at the second and third derivative, it is clear that there are also discontinuities associated with points like
t=
,
1+
,
2+
propagated from the jump discontinuities in
x
(t).
Plot the second derivative
| Out[111]= |  |
|
In fact, there is a whole tree of discontinuities that are propagated forward in time. A way of determining and displaying the discontinuity tree for a solution interval is shown in the subsection below.
Discontinuity Tree
Define a command that gives the graph for the propagated discontinuities for a DDE with the given delays |
Get the discontinuity tree for the example above up to t=8.
| Out[113]= |  |
|
Define a command that shows a plot of x (k) (t) and x (k+1) (t) for a discontinuity of order k. |
Plot as a layered graph, showing the discontinuity plot as a tooltip for each discontinuity.
| Out[117]= |  |
|
Storing history data
Once the solution has advanced beyond the first discontinuity point, some of the delayed values that need to be computed are outside of the domain of the initial history function and the computed solution needs to be used to get the values, typically be interpolating between steps previously taken. For the DDE solution to be accurate it is essential that the interpolation be as accurate as the method. This is achieved by using dense output for the ODE integration method (the output you get if you use the option
InterpolationOrder->All in
NDSolve).
NDSolve has a general algorithm for obtaining dense output from most methods, so you can use just about any method as the integrator. Some methods, including the default for DDEs have their own way of getting dense output which is usually more efficient than the general method. Methods that are low enough order, such as
"ExplicitRungeKutta" with
"DifferenceOrder"->3 can just use a cubic Hermite polynomial as the dense output so there is essentially no extra cost in keeping the history.
Since the history data is accessed frequently, it needs to have a quick look up mechanism to determine which step to interpolate within. In
NDSolve, this is done with a binary search mechanism and the search time is negligible compared with the cost of actual function evaluation.
The data for each successful step is saved before attempting the next step and is saved in a data structure that can repeatedly be expanded efficiently. When
NDSolve produces the solution, it simply takes this data and restructures it into an
InterpolatingFunction object, so DDE solutions are always returned with dense output.
The method of steps
For constant delays, it is possible to get the entire set of discontinuities as fixed time. The idea of the method of steps is to simply integrate the smooth function over these intervals and restart on the next interval, being sure to reevaluate the function from the right. As long as the intervals do not get too small, the method works quite well in practice.
The method currently implemented for
NDSolve is based on the method of steps.
Symbolic method of steps
This section defines a symbolic method of steps that illustrates how the method works. Note that to keep the code simpler and more to the point, it does not do any real argument checking. Also, the data structure and look up for the history is not done in an efficient way, but for symbolic solutions this is a minor issue.
Use DSolve to integrate over an interval where the solution is smooth. |
Define a method of steps function that returns Piecewise functions. |
| Out[24]= |  |
|
| Out[25]= |  |
|
Check the quality of the solution found by NDSolve by comparing to the exact solution.
| Out[27]= |  |
|
The method will also work for neutral DDEs
| Out[28]= |  |
|
| Out[29]= |  |
|
Check the quality of the solution found by NDSolve by comparing to the exact solution.
| Out[31]= |  |
|
The symbolic method will also work with symbolic parameter values as long as
DSolve is able to still able to find the solution.
Find the solution to a simple linear DDE with symbolic coefficients.
| Out[32]= |  |
|
The reason the code was designed to take lists was so that it would work with systems
| Out[33]= |  |
|
| Out[34]= |  |
|
Check the quality of the solution found by NDSolve by comparing to the exact solution.
| Out[36]= |  |
|
Since the method computes the discontinuity tree, it will also work for multiple constant delays. However, with multiple delays, the solution may become quite complicated quickly and
DSolve can bog down with huge expressions.
Solve a nonlinear neutral DDE with two delays.
| Out[37]= |  |
|
| Out[38]= |  |
|
Check the quality of the solution found by NDSolve by comparing to the exact solution.
| Out[40]= |  |
|
Examples
Lotka-Volterra equations with delay
The
Lotka-Volterra system models the growth and interaction of animal species assuming that the effect of one species on another is continuous and immediate. A delayed effect of one species on another can be modeled by introducing time lags in the interaction terms.
With no delays,
1=
2=0 the system (1) has an invariant
H (t)=2ln Y1-Y1+ln Y2-Y1 that is constant for all
t and there is a (neutrally) stable periodic solution.
Compare the solution with and without delays.
| Out[16]= |  |
|
In this example, the effect of even a small delay is to destabilize the periodic orbit. With different parameters in the delayed Lotka-Volterra system it has been shown that there are globally attractive equilibria.[
TZ08]
Enzyme kinetics
modeling enzyme kinetics where
Is is a substrate supply maintained at a constant level and
n molecules of the end product
y4 inhibits the reaction step
y1→y2. [
HNW93]
The system has an equilibrium when
{y1=Is/z, y2=y3=Is, y4=2 Is}.
Investigate solutions of (1) starting a small perturbation away from the equilibrium. |
Mackey-Glass equation
The Mackey-Glass equation x'[t]=a x[t-

]/(1 + x[t-

]^n) - b x[t] was proposed to model the production of white blood cells. There are both periodic and chaotic solutions.
Here is a periodic solution of the Mackey-Glass equation. The plot is only shown after t=300 to let transients die out.
| Out[32]= |  |
|
Here is a chaotic solution of the Mackey-Glass equation.
| Out[45]= |  |
|
It is interesting to check the accuracy of the chaotic solution.
Compute the chaotic solution with another method and plot log10|d| for the difference d between x (t) computed by the different methods.
| Out[17]= |  |
|
By the end of the interval, the differences between methods is order 1. Large deviation is typical in chaotic systems and in practice it is not possible or even necessary to get a very accurate solution for a large interval. However, if you do want a high quality solution,
NDSolve allows you to use higher precision. For DDEs with higher precision, the
"StiffnessSwitching" method is recommended.
Compute the chaotic solution with higher precision and tolerances. |
Plot the three solutions near the final time.
| Out[19]= |  |
|