21.04.2015 Views

The Computable Differential Equation Lecture ... - Bruce E. Shapiro

The Computable Differential Equation Lecture ... - Bruce E. Shapiro

The Computable Differential Equation Lecture ... - Bruce E. Shapiro

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

144 CHAPTER 7. DELAY DIFFERENTIAL EQUATIONS<br />

✬<br />

Algorithm 7.1. Method of Steps To solve the delay differential<br />

equation<br />

on the interval (t 0 , Kτ), K ∈ Z + .<br />

y ′ (t) = f(t, y(t), y(t − τ)) (7.66)<br />

y(t) = g(t), t 0 − τ < t < t 0 (7.67)<br />

1. Input n, number of points in the mesh; set h = τ/n.<br />

2. For i = 0, . . . , K − 1,<br />

(a) Set p(t) = y(t − τ) (either as a function or an array of<br />

data to index into).<br />

(b) Solve the following IVP using any solver you choose:<br />

y ′ (t) = f(t, y(t), p(t)) (7.68)<br />

y(t 0 + iτ) = p(t 0 ) (7.69)<br />

on the interval (t 0 + iτ, t 0 + (i + 1)τ).<br />

✩<br />

✫<br />

✪<br />

We choose to store our initial data as a set of points evaluated at the delayed times<br />

t 0 − τ, t 0 − τ + h, t 0 − τ + 2h, . . . , t 0 in an array. <strong>The</strong> conversion between the array<br />

index i and the time t is given by the formula<br />

i = 1 + n(1 + t/τ) (7.70)<br />

This formula works find so long as t falls on a mesh point; if not, we have two choices:<br />

interpolation (more accurate); and rounding (simpler). Since this is an illustrative<br />

implementation, we choose the simpler method, and force the value of i to be an<br />

integer in the following code:<br />

index[t , tau , n ] := Module[{},<br />

If[t < -tau , Return[$Failed]];<br />

Return[Floor[1 + n(1 + t/tau)]];<br />

];<br />

<strong>The</strong> function index[t, tau, n] returns the value of i corresponding to a given<br />

value of t , based on the mesh size n and delay tau . Assuming that our initial<br />

data is stored in the array data, to get the value of f(t − τ) would would call<br />

data[[index[t-tau, tau, n]]]<br />

and to implement our function f(t) = −y(t − τ)<br />

f[t ] := -1.0*data[[index[t - tau, tau, n]]];<br />

Math 582B, Spring 2007<br />

California State University Northridge<br />

c○2007, B.E.<strong>Shapiro</strong><br />

Last revised: May 23, 2007

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!