raymond_seroul

24 Reputation

2 Badges

15 years, 114 days

MaplePrimes Activity


These are answers submitted by raymond_seroul

 

Dear Preben Alsholm,

thank you a lot for your aid.

Avoiding the array was only aesthetic.

I am still enjoying my delayed differential equation. As the previous code est very slow (because of recursive calls),
I tried to use the option 'piecewise'. But the documentatiohn is osbcure and does not help. I tried the code

xx := t -> 1  ;
P := plot(xx, -1 .. 0);

xnum := dsolve({x(0) = xx(0), (D(x))(t) = -xx(t-1)},
x(t), type = numeric, output = piecewise, range = 0 .. 1, 'known' = xx);
yy := unapply(rhs(xnum(t)[2]), rhs(xnum[1]));

P := P, plot(yy, 0 .. 1);

xnum := dsolve({x(1) = ('yy')(1), (D(x))(t) = -('yy')(t-1)},
x(t), type = numeric, output = piecewise, range = 1 .. 2, 'known' = yy);
zz := unapply(rhs(xnum(t)[2]), rhs(xnum[1]));

P := P, plot(zz, 1 .. 2);

P := P, plot(tt, 2 .. 3);
display([P], axes = boxed);

But it does not work : i get the message

"Warning, cannot evaluate the solution further right of 1.9999993, probably a singularity."

Questions :

1) Do output = piecewise really works ?

2) The affectation  yy := unapply(rhs(xnum(t)[2]), rhs(xnum[1]));
looks awkward, but I did not discover something more elegant.

3) The real problem is that Maple does not consider a dsolve(..., type = numeric)
as a genuine function. Is there a philosophy ?

Raymond Séroul, Université de Strasbourg











 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Raymond Séroul

Université de Strasbourg

 

 

I want to integrate the delayed differential equation

x'(t) = -x(t-1)  for t ≥ 0  and x(t) = 1 for -1 ≤ t ≤ 0.

The idea is to evaluate x on [0,1], [1,2], and so on.

The following code works, but is very, very slow si N > 8 :

theta := t -> 1;
P := plot(theta, -1 .. 0);
N := 3;
xx := array(0 .. N+1);
xx[0] := theta;
for n from 0 to N do
xnum := dsolve({x(n) = xx[n](n), x'(t)(t) = -xx[n](t-1)},
x(t), type = numeric, output = listprocedure, 'known' = xx[n]);
xx[n+1] := rhs(xnum[2]);
P := P, plot(xx[n+1], n .. n+1)
od ;

display([P], axes = boxed)

But if I suppress the array xx[0..N+1] to get a better loop and write

theta := t -> 1;
P := plot(theta, -1 .. 0);
N := 3;
xx := theta;
for n from 0 to N do
xnum := dsolve({x(n) = xx(n), x'(t) = -xx(t-1)},
x(t), type = numeric, output = listprocedure, 'known' = xx);
xx := rhs(xnum[2]);
P := P, plot(xx, n .. n+1)
od ;

display([P], axes = boxed);

Maple breaks its connexion with his kernel and became useless.

Raymond Séroul, Université de Strasbourg

 

Page 1 of 1