How to | Solve Delay Differential Equations

You can use the standard differential equation solving function, NDSolve, to numerically solve delay differential equations with constant delays. It returns an interpolation function that can then be easily used with other functions.

Take the first-order delay differential equation with delay 1 and initial history function . Use NDSolve to solve it and store the solution in . The first argument to NDSolve is the delay differential equation, the second argument is the variable you want to solve for, and the third is the range of the variable:

In[1]:=
Click for copyable input
Out[1]=

Plot the solution and its first derivative . To see these in different colors, wrap Evaluate around them. You will also need to load the Plot Legends Package if you want to add a legend to the plot:

In[2]:=
Click for copyable input
In[3]:=
Click for copyable input
Out[3]=

Use Manipulate to let you change the initial function:

Solve a first-order delay differential equation with two constant delays, and 1, and the initial history function :

In[5]:=
Click for copyable input
Out[5]=

Plot the solution and its first derivative . To see these in different colors, wrap Evaluate around them:

In[6]:=
Click for copyable input
Out[6]=

Solve a second-order delay differential equation with constant delay 1 and the initial history function :

In[7]:=
Click for copyable input
Out[7]=

Plot the solution and its first two derivatives and . To see these in different colors, wrap Evaluate around them:

In[8]:=
Click for copyable input
Out[8]=

For an explanation of the terms associated with delay differential equations, see "Delay Differential Equations".

New to Mathematica? Find your learning path »
Have a question? Ask support »