中立型 DDE

${\mathit{y}}^{\prime }\left(\mathit{t}\right)=1+\mathit{y}\left(\mathit{t}\right)-2{\mathit{y}\left(\frac{\mathit{t}}{2}\right)}^{2}-{\mathit{y}}^{\prime }\left(\mathit{t}-\pi \right)$

$\mathit{t}\le 0$ 时，历史解函数是 $\mathit{y}\left(\mathit{t}\right)=\mathrm{cos}\left(\mathit{t}\right)$

编写时滞代码

```function dy = dely(t,y) dy = t/2; end ```

```function dyp = delyp(t,y) dyp = t-pi; end ```

编写方程代码

• `t` 是时间（自变量）。

• `y` 是解（因变量）。

• `ydel` 包含 $\mathit{y}$ 的时滞。

• `ypdel` 包含 ${\mathit{y}}^{\prime }=\frac{\mathrm{dy}}{\mathrm{dt}}$ 的时滞。

• `ydel`$\text{}\to \text{}\text{}\mathit{y}\left(\frac{\mathit{t}}{2}\right)$

• `ypdel`$\text{}\to \text{}{\mathit{y}}^{\prime }\left(\mathit{t}-\pi \right)\text{}$

```function yp = ddefun(t,y,ydel,ypdel) yp = 1 + y - 2*ydel^2 - ypdel; end ```

编写历史解代码

```function y = history(t) y = cos(t); end ```

求解方程

```tspan = [0 pi]; sol = ddensd(@ddefun, @dely, @delyp, @history, [0,pi]);```

对解进行绘图

`0``pi` 之间以 20 个等间距点计算解。

```tn = linspace(0,pi,20); yn = deval(sol,tn);```

```th = linspace(-pi,0); yh = history(th); ta = linspace(0,pi); ya = cos(ta); plot(th,yh,tn,yn,'o',ta,ya) legend('History','Numerical','Analytical','Location','NorthWest') xlabel('Time t') ylabel('Solution y') title('Example of Paul with 1 Equation and 2 Delay Functions') axis([-3.5 3.5 -1.5 1.5])```

局部函数

```function yp = ddefun(t,y,ydel,ypdel) % equation being solved yp = 1 + y - 2*ydel^2 - ypdel; end %------------------------------------------- function dy = dely(t,y) % delay for y dy = t/2; end %------------------------------------------- function dyp = delyp(t,y) % delay for y' dyp = t-pi; end %------------------------------------------- function y = history(t) % history function for t < 0 y = cos(t); end %-------------------------------------------```

参考

[1] Paul, C.A.H.“A Test Set of Functional Differential Equations.”Numerical Analysis Reports.No. 243.Manchester, UK:Math Department, University of Manchester, 1994.