State-Dependent Delay Problem

This example shows how to use ddesd to solve a system of two DDEs with a state-dependent delay. This system of DDEs was used as a test problem by Enright and Hayashi [1].

Click ddex3.mddex3.m or type edit ddex3.m in a command window to view the complete code for this example in an editor.

The equations for this system are:


The analytical solution


is used as the history for t ≤ 0.1 and the equations are solved on [0.1, 5] with ddesd rather than dde23. The ddesd function is appropriate in this case because the first factor in the second equation has the form y2(d(y)) with a delay that depends on the second component of the solution.

  1. Create a new program file in the editor. This file will contain a main function and three local functions.

  2. Code the system of DDEs as a local function.

    function dydt = ddex3de(t,y,Z)
      dydt = [y(2); -Z(2)*y(2)^2*exp(1 - y(2))];
  3. Define the delay as a local function.

    function d = ddex3delay(t,y)
      d = exp(1 - y(2));
  4. Define the solution history as a local function.

    function v = ddex3hist(t)  
      v = [log(t); 1./t];
  5. Define the interval of integration and solve the system. Add this code to the main function in your program file.

    tspan = [0.1 5];
    sol = ddesd(@ddex3de,@ddex3delay,@ddex3hist,tspan);
  6. Use the history function to calculate the analytical solution within the integration interval. Add this code to the main function.

    texact = linspace(0.1,5);
    yexact = ddex3hist(texact);
  7. Plot the numerical solution on the same axes as the analytical solution. Add this code to the main function.

    legend('y_1, exact','y_2, exact','y_1, ddesd','y_2, ddesd')
    xlabel('time t')
    ylabel('solution y')
    title('D1 problem of Enright and Hayashi')
  8. Run your program to generate and plot the results.


[1] Enright, W.H. and H. Hayashi. "The Evaluation of Numerical Software for Delay Differential Equations." In Proceedings of the IFIP TC2/WG2.5 working conference on Quality of numerical software: assessment and enhancement. (R.F. Boisvert, ed.). London, UK: Chapman & Hall, Ltd., pp. 179-193.

See Also

Related Examples

Was this topic helpful?