Search code examples
wolfram-mathematicasolverdifferential-equations

Delayed system of differential equations


I wrote the following DDE in Mathematica:

sol = NDSolve[{ x'[t]=0.2x[t]+1.4y[t]+0.5y[t-𝜏]-2,
                y'[t]=-0.2x[t]+0.4y[t]+2,
                x[t /; t <= 0] == 2, 
                y[t /; t <= 0] == 2},
                {x,y},{t,0,10} ]

But I'm getting those errors :

Item 2 requested in Delayed time '1' = '2' computed at '3' = '4' did not evaluate to a real number. out of range; 1 items available.

General::stop: Further output of StringForm::sfr will be suppressed during this calculation.

NDSolve::rdelay: Delayed time –1. 𝜏= '2' computed at '3' = '4' did not evaluate to a real number.

Could you please explain how I can fix these errors?


Solution

  • As mentioned by @Bill in the comments, the following would fix the error.

    𝜏=1;NDSolve[{x'[t]==0.2x[t]+1.4y[t]+0.5y[t-𝜏]-2,
    y'[t]==-0.2x[t]+0.4y[t]+2,x[t/;t<=0]==2,y[t/;t<=0]==2},{x,y},{t,0,10}]
    

    In my first version of the code, 𝜏 was not initialized, and '=' instead of '==' were used.