Example 2

We show how to get output at specific points with Example 5 of [23], a scalar equation that exhibits chaotic behavior. We solve the equation
y(t)
=
2  y(t-2)
1 + y(t-2)9.65
- y(t)
(3)
on [0,100] with history y(t) = 0.5 for t 0.

Output from dde23 is not just formally different from that of ode23. dde23 computes an approximate solution S(t) valid throughout tspan and places in sol the information necessary to evaluate it. This evaluation is done with ddeval. All you have to do is supply the solution structure and an array t of points where you want the values of S(t) and optionally S(t):

   [S,Sp] = ddeval(sol,t);
With this form of output, you can solve a DDE just once and then obtain inexpensively as many solution values as you like, anywhere you like. The numerical solution itself is continuous and has a continuous derivative, so you can always get a smooth graph by evaluating it at enough points with ddeval.

The example of [23] plots y(t-2) against y(t). This is quite a common task in nonlinear dynamics, but we cannot proceed as in Example 1. That is because the entries of sol.x are not equally spaced: If t* appears in sol.x, we have an approximation to y(t*) in sol.y, but generally t*-2 does not appear in sol.x, so we do not have an approximation to y(t*-2). ddeval makes such plots easy. In exam2.m we first define an array t of 1000 equally spaced points in [2,100] and obtain solution values at these points with ddeval. We then use ddeval a second time to evaluate the solution at the entries of t-2. In this way we obtain values approximating both y(t) and y(t-2) for the same t. This might seem like a lot of plot points, but ddeval is just evaluating a piecewise-polynomial function and is coded to take advantage of fast builtin functions and vectorization, so this is not expensive and results in a smooth graph.

Because MATLAB does not distinguish scalars and vectors of one component, the single DDE can be coded as

   function v = exam2f(t,y,Z)
   v = 2*Z/(1 + Z^9.65) - y;
The complete program exam2.m to compute and plot y(t -2) against y(t) is
 sol = dde23('exam2f',2,0.5,[0, 100]);

 t = linspace(2,100,1000);
 y = ddeval(sol,t);
 ylag = ddeval(sol,t - 2);
 plot(y,ylag);
 title('Figure 2. Example 5 of Wille'' and Baker.')
 xlabel('y(t)');
 ylabel('y(t-2)');
 axis([0 1.5 0 1.5])

images/2.gif

Reference

[23]
D.R. Willé and C.T.H. Baker, DELSOL - a numerical code for the solution of systems of delay-differential equations, Appl. Numer. Math., 9 (1992) 223-234.