DDEs

Function Summary

DDE Solvers

Solver

Description

dde23

Solve initial value problems for delay differential equations with constant delays.

ddesd

Solve initial value problems for delay differential equations with general delays.

DDE Helper Functions

Function

Description

deval

Evaluate the numerical solution using the output of dde23 or ddesd.

DDE Solver Options

Use these functions to create, alter, or access an options structure. An options structure contains named properties, the values of which are passed to dde23 or ddesd, thus affecting the solution of the problem.

Function

Description

ddeset

Create/alter the DDE options structure.

ddeget

Extract properties from options structure created with ddeset.

Initial Value Problems

The DDE dde23 solver can solve systems of ordinary differential equations, such as

y prime (t) = f(t, y(t), y(t minus tau sub 1),..., y(t minus tau sub k))

where t is the independent variable, y is the dependent variable, and y prime represents (derivative of y with respect to t) d y / d t. The delays (lags) tau sub 1 through tau sub k are positive constants. The solver ddesd allows delays that depend on and .

History and Initial Values

In an initial value problem, you seek the solution on an interval [t sub 0, t sub f] with t sub 0 < t sub f. The DDE shows that y prime (t) depends on values of the solution at times prior to t. In particular, y prime (t sub 0) depends on y( t sub 0 minus tau sub 1) through y(t sub 0 minus tau sub k). Because of this, a solution on [t sub 0, t sub f] depends on its values for t less than or equal t sub 0, i.e., its history S(t).

Propagation of Discontinuities

Generally, the solution y(t) of an IVP for a system of DDEs has a jump in its first derivative at the initial point t sub 0 because the first derivative of the history function does not satisfy the DDE there. A discontinuity in any derivative propagates into the future at spacings of tau sub 1, tau sub 2, ..., tau sub k when the delays are constant, and in a more complicated way when they are not. For the DDEs solved by dde23 and ddesd, the solution becomes smoother as the integration proceeds.

Types of Solvers

This section describes:

DDE Solver dde23
DDE Solver ddesd

The basic syntax for the two solvers is shown in the function reference pages for dde23 and ddesd.

DDE Solver dde23

The function dde23 solves initial value problems for DDEs with constant delays. It integrates a system of first-order differential equations

y prime (t) = f(t, y(t), y(t minus tau sub 1), ..., y(t minus tau sub k))

on the interval [t sub 0, t sub f], with t sub 0 < t sub f and given history y(t) = S(t) for t less than or equal t sub 0.

dde23 produces a solution that is continuous on [t sub 0, t sub f]. You can use the function deval and the output of dde23 to evaluate the solution at specific points on the interval of integration.

dde23 tracks low-order discontinuities and integrates the differential equations with the explicit Runge-Kutta (2,3) pair and interpolant used by ode23. The Runge-Kutta formulas are implicit for step sizes longer than the delays. When the solution is smooth enough that steps this big are justified, the implicit formulas are evaluated by a predictor-corrector iteration.

DDE Solver ddesd

The function ddesd solves initial value problems for DDEs with general delays. It integrates a system of first-order differential equations

on the interval [t sub 0, t sub f], with t sub 0 < t sub f, where delays can depend on both and . Use the function deval and the output of ddesd to evaluate the solution at specific points on the interval of integration.

ddesd integrates with the classic four-stage, fourth-order explicit Runge-Kutta method, and controls the size of the residual of a natural interpolant. It uses iteration to take steps that are longer than the delays. For further details, see "Solving ODEs and DDEs with Residual Control," L.F. Shampine, Applied Numerical Mathematics, 52 (2005), pp 113-127.

Discontinuities

dde23 performs better if it is informed of discontinuities in the history and at known locations. Discontinuities may be specified by event functions. There is a property with which you can specify a solution that is different from the value given by the history function.

Discontinuity

Property

Comments

At the initial value t = t sub 0

InitialY

Generally the initial value y (t sub 0) is the value S(t sub 0) returned by the history function, which is to say that the solution is continuous at the initial point. However, if this is not the case, supply a different initial value using the InitialY property.

In the history, i.e., the solution at t < t sub 0, or in the equation coefficients for t > t sub 0

Jumps

Provide the known locations t of the discontinuities in a vector as the value of the Jumps property. Applies only to dde23.

State-dependent

Events

dde23 and ddesd use the events function you supply to locate these discontinuities. When the solver finds such a discontinuity, restart the integration to continue. Specify the solution structure for the current integration as the history for the new integration. The solver extends each element of the solution structure after each restart so that the final structure provides the solution for the whole interval of integration. If the new problem involves a change in the solution, use the InitialY property to specify the initial value for the new integration.

Integrator Options

The default integration properties in the DDE solver dde23 are selected to handle common problems. In some cases, you can improve solver performance by overriding these defaults. You do this by supplying dde23 with an options structure that specifies one or more property values.

For example, to change the relative error tolerance of dde23 from the default value of 1e-3 to 1e-4,

  1. Create an options structure using the function ddeset by entering

    options = ddeset('RelTol', 1e-4);
    
  2. Pass the options structure to dde23 as follows:

    sol = dde23(ddefun,lags,history,tspan,options)
    

For a complete description of the available options, see the reference page for ddeset.

Examples

Constant Delay

Solving the System.   This example illustrates the straightforward formulation, computation, and display of the solution of a system of DDEs with constant delays. The history is constant, which is often the case. The differential equations are

Equation 1: y sub 1 prime = y sub 1 (t minus 1).Equation 2: y sub 2 prime = y sub 1 (t minus 1) + y sub 2 (t minus 0.2).Equation 3: y sub 3 prime (t) = y sub 2 (t).

The example solves the equations on [0,5] with history

Equation 1: y sub 1 (t) = 1.Equation 2: y sub 2 (t) = 1.Equation 3: y sub 3 (t) = 1.

for t less than or equal 0.

  1. Rewrite the problem as a first-order system. To use dde23, you must rewrite the equations as an equivalent system of first-order differential equations. Do this just as you would when solving IVPs and BVPs for ODEs. However, this example needs no such preparation because it already has the form of a first-order system of equations.

  2. Identify the lags. The delays (lags) tau sub 1 through tau sub k are supplied to dde23 as a vector. For the example we could use

    lags = [1,0.2];
    

    In coding the differential equations, tau sub j = lags(j).

  3. Code the system of first-order DDEs. Once you represent the equations as a first-order system, and specify lags, you can code the equations as a function that dde23 can use.

    This code represents the system in the function, ddex1de.

    function dydt = ddex1de(t,y,Z)
    ylag1 = Z(:,1);
    ylag2 = Z(:,2);
    dydt = [ylag1(1)
            ylag1(1) + ylag2(2)
            y(2)               ];
    
  4. Code the history function. The history function for this example is

    function S = ddex1hist(t)
    S = ones(3,1);
    
  5. Apply the DDE solver. The example now calls dde23 with the functions ddex1de and ddex1hist.

    sol = dde23(@ddex1de,lags,@ddex1hist,[0,5]);
    

    Here the example supplies the interval of integration [0,5] directly. Because the history is constant, we could also call dde23 by

    sol = dde23(@ddex1de,lags,ones(3,1),[0,5]);
    
  6. View the results. Complete the example by displaying the results. dde23 returns the mesh it selects and the solution there as fields in the solution structure sol. Often, these provide a smooth graph.

    plot(sol.x,sol.y);
    title('An example of Wille'' and Baker');
    xlabel('time t');
    ylabel('solution y');
    legend('y_1','y_2','y_3',2)
    

    plot of An example of Wille and Baker. Label of x axis is time t. Label of y axis is solution y.

Evaluating the Solution.   The method implemented in dde23 produces a continuous solution over the whole interval of integration [t sub 0, t sub f]. You can evaluate the approximate solution, S(t), at any point in [t sub 0, t sub f] using the helper function deval and the structure sol returned by dde23.

Sint = deval(sol,tint)

The deval function is vectorized. For a vector tint, the ith column of Sint approximates the solution y(tint(i)).

Using the output sol from the previous example, this code evaluates the numerical solution at 100 equally spaced points in the interval [0,5] and plots the result.

tint = linspace(0,5);
Sint = deval(sol,tint);
plot(tint,Sint);

State-Dependent Delay

This example solves a system of two DDEs with state-dependent delay that was used as a test problem by W.H. Enright and H. Hayashi [10] because it has an analytical solution. The differential equations are

The analytical solution

is used as the history for and the equations are solved on [0.1, 5]. The only thing different about solving this example is that it must be solved with ddesd rather than dde23. This is because the first factor in the second equation has the form with a delay that depends on the second component of the solution. The delay is provided to ddesd with a function like

function d = ddex3delay(t,y)
% State dependent delay function for DDEX3
d = exp(1 - y(2));

Cardiovascular Model

This example solves a cardiovascular model due to J. T. Ottesen [6]. The equations are integrated over the interval [0,1000]. The situation of interest is when the peripheral pressure R is reduced exponentially from its value of 1.05 to 0.84 beginning at t = 600.

This is a problem with one delay, a constant history, and three differential equations with fourteen physical parameters. It has a discontinuity in a low order derivative at t = 600.

In ddex2, the fourteen physical parameters are set as fields in a structure p that is shared with nested functions. The function ddex2de for evaluating the equations begins with

function dydt = ddex2de(t,y,Z)
if t <= 600
   p.R = 1.05;
else
   p.R = 0.21 * exp(600-t) + 0.84;
end
.
.
.

Jumps Property.   The peripheral pressure R is a continuous function of t, but it does not have a continuous derivative at t = 600. The example uses the Jumps property to inform dde23 about the location of this discontinuity.

opts = ddeset('Jumps',600);

After defining the delay tau and the constant history, the call is

sol = dde23(@ddex2de,tau,history,[0, 1000],opts);

The demo ddex2 plots only the third component, the heart rate, which shows a sharp change at t = 600.

Restarting.   The example could have solved this problem by breaking it into two pieces

sol = dde23(@ddex2de,tau,history,[0, 600]);
sol = dde23(@ddex2de,tau,sol,[600, 1000]);

The solution structure sol on the interval [0,600] serves as history for restarting the integration at t = 600. In the second call, dde23 extends sol so that on return the solution is available on the whole interval [0,1000]. That is, after this second return,

Sint = deval(sol,[300,900]);

evaluates the solution obtained in the first integration at t = 300, and the solution obtained in the second integration at t = 900.

When discontinuities occur in low order derivatives at points known in advance, it is better to use the Jumps property. This is not an option with ddesd, which handles discontinuities in a different way. When you use event functions to locate such discontinuities, you must restart the integration at discontinuities.

Plot of heart rate for baroflex feedback mechanism

Additional Examples

The following additional examples are available. Type

edit examplename

to view the code and

examplename

to run the example.

Example

Description

ddex1

Straightforward example

ddex2

Cardiovascular model with discontinuities

ddex3

Problem involving state-dependent delays

Additional examples are provided by "Tutorial on Solving DDEs with DDE23," available at http://www.mathworks.com/dde_tutorial.

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS