Question: the mysterious "events" command

I am using Maple 12.01 and I am using dsolve to solve a second order ODE;  example :

eq:=diff(y(t),t,t)+sin(t)*diff(y(t),t)+y(t)^2-5*y(t)=0;

ic:=a->[D(y)(0)=0,y(0)=a]; # initial conditions.
 

I want to investigate the  values of z(t, y, y') when g(t, y,y') = 0. Here z might be y''' or cos(t y') and g  might be y(t)-4.

What I would like to do is create an Array whose nth entry is of the form [ tn, z(tn,y(tn), y'(tn)]  where tn is the nth value of t at which the condition g(t, y,y') = 0 is satisfied.

I know that there is an events option in dsolve and I undersstand that I need a trigger – g(t, y,y') = 0 in the above example – and an action to be taken when the trigger is set off.

I really do not understandthe action part. I cobbled together the following code that sorta does the job:

ans:=a->dsolve([eq,op(icd(a))],{y(t)},numeric,events=[[[y(t)-4=0,diff(y(t),t)> 0],[z(t)=diff(y(t),t)^2]]],discrete_variables=[z(t)::float]);
odeplot(ans(0.3),[[t,y(t)],[t,z(t)]],t=0..10);
 

The plot shows me the value of z(t) and jumps at discrete values so I can eyeball the values of tn. The discrete variable z is not accessible outside the dsolve command so I cannot determine its value precisely.

Can anyone help?

Thanks in advance,

rick

BTW, since the action part of the command is completely new and is not entirely consistent with usual Maple syntax , e.g., one uses = for assignment inside events rather than :=, would it not have been useful to have at least 1 example of using discrete variables?
 

 

Please Wait...