Question: Why doesn't dsolve[events] return the good results?

Hi,

Why extracting the features of the events doesn't return the good results when executed within a loop (see the pink test) ?

Thanks in advance.

PS: please, spare me  replies of the type "you can solve this equation formally"

 

restart;

interface(version);

`Standard Worksheet Interface, Maple 2015.2, Mac OS X, December 21 2015 Build ID 1097895`

(1)

sys := { diff(x(t), t) = 1, x(0) = 0 }:
evs := [ [x(t)-0.1, none],  [x(t)-0.3, none], [x(t)-0.5, none] ]:
sol := dsolve(sys, numeric, events=evs):

plots:-odeplot(sol, [t, x(t)], t=0..0.5, gridlines=true);

 

# times that fired the events

sol(1): # initialization

sol(eventfired=[1]);
sol(eventfired=[2]);
sol(eventfired=[3]);
 

[HFloat(0.1)]

 

[HFloat(0.3)]

 

[HFloat(0.49999999999999994)]

(2)

# Same times computed  within a loop

for i from 1 to 3 do
  te := op(sol(eventfired=[i]));
end do;

HFloat(0.1)

 

HFloat(0.3)

 

HFloat(0.49999999999999994)

(3)

# Values of x(t) computed  within a loop
#
# Why are calues for events 2 and 3 wrong ?
for i from 1 to 3 do
  te := op(sol(eventfired=[i]));
# xe := sol(te);             # this doesn't return the correct result,
# xe := subs(sol(te), x(t)); # this doesn't work neither
  xe := eval(x(t), sol(te)); # this doesn't work neither
end do;

HFloat(0.1)

 

HFloat(0.1)

 

HFloat(0.0)

 

HFloat(0.0)

 

HFloat(0.0)

 

HFloat(0.0)

(4)

 


 

Download Incomprehensible.mw

 

Please Wait...