Delay differential equations

| categories: odes | View Comments



Delay differential equations (Problem 1 on page 32).

A model for predator-prey populations is given by:

$y_1'(t) = a y_1(t) + b y_1(t) y_2(t)$

$y_2'(t) = c y_2(t) + d y_1(t) y_2(t)$

where $y_1$ and $y_2$ are the prey and predators. These are ordinary differential equations that are straightforward to solve.

If there is a resource limitation on the prey and assuming the birth rate of predators responds to changes in the magnitude of the population y1 of prey and the population y2 of predators only after a time delay $\tau$, we can arrive at a new set of delay differential equations:

$y_1'(t) = a y_1(t)(1-y_1(t)/m) + b y_1(t) y_2(t)$

$y_2'(t) = c y_2(t) + d y_1(t-\tau) y_2(t-\tau)$

these equations cannot be solved with ordinary ODE solvers, because the value of the solution at any time $t$ depends on the value of the solution some time $\tau$ ago. So, even at $t=0$, we have to know the history to know the initial derivative is. We use the dde23 function in Matlab to solve this problem.

function main
clear all; close all; clc

The non-delay model

We first solve the ordinary model so we can see the impact of adding the delay.

a =0.25;
b= -0.01;
c= -1.00;

y10 = 80; % initial population of prey
y20 = 30; % initial population of predator
tspan = [0 200]; % time span to integrate over
[t,Y] = ode45(@myode,tspan,[y10 y20]);

y1 = Y(:,1);
y2 = Y(:,2);

phase portrait of solution

You can see a stable limit cycle (purely oscillatory behavior) in the population of prey and predators.

    function dYdt = myode(t,Y)
        % ordinary model
        y1 = Y(1);
        y2 = Y(2);

        dy1dt = a*y1 + b*y1*y2;
        dy2dt = c*y2 + d*y1*y2;

        dYdt = [dy1dt; dy2dt];

The delay model

Now we solve the model with the delays. We solve this example with a delay of $\tau=1$.

lags = [1]; % this is where we specify the vector of taus

% we need a history function that is a column vector giving the value of y1
% and y2 in the past. Here we make these constant values.
     function y = history(t)
         y = [80; 30];

% we define the function for the delay. the Y variable is the same as you
% should be used to from an ordinary differential equation. Z is the values
% of all the delayed variables.
    function  dYdt = ddefun(t,Y,Z)
        m = 200; % additional variable
        y1 = Y(1);
        y2 = Y(2);

        % Z(:,1) = [y1(t - tau_1); y2(t - tau_2)]
        y1_tau1 = Z(1,1);
        y2_tau1 = Z(2,1);

        dy1dt = a*y1*(1-y1/m) + b*y1*y2;
        dy2dt = c*y2 + d*y1_tau1*y2_tau1;

        dYdt = [dy1dt; dy2dt];

now we solve with dde23

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

y1 = sol.y(1,:); % note the y-solution is a row-wise matrix.
y2 = sol.y(2,:);
sol = 

     solver: 'dde23'
    history: @dde_example1/history
    discont: [0 1 2 3]
          x: [1x127 double]
          y: [2x127 double]
      stats: [1x1 struct]
         yp: [2x127 double]

Add delay solution to the ordinary solution

hold all

you can see the delay and resource limit significantly affect the solution. Here, it damps the oscillatory behavior, and seems to be leading to steady state population values.

legend 'y1' 'y2'

% categories: ODEs
% tags: delay differential equation
Read and Post Comments