Question: What actions after an event? (ODE numeric events)

I am trying to understand the use of "events" in solving ode's, specifically the possible actions.
From the help pages:

Events are specified by the events=[event1,event2,...] option in the call to dsolve[numeric], where each event is a list of [trigger,action] pairs, where the trigger describes the trigger of the event, and the action describes the action to perform when the event is triggered.

It then goes on to list possible actions, for example,

u(t) = -u(t): execute statement when triggered
– [u(t) = -u(t), y(t) = -y(t)]: execute statements when triggered
[If(y(t) < 0, y(t) = -y(t), halt)]: execute statements conditionally when triggered

I tried to use the first one unsuccessfully several ways:
This works:dsolve({eq, y(0) = 1, (D(y))(0) = -1}, numeric, events = [[x+y(x) = 15, halt]])

but dsolve({eq, y(0) = 1, (D(y))(0) = -1}, numeric, events = [[y(x) = 0,[ 'print("Yes'")', halt]]]) does not

nor does any variant of that using print.

Also, I cannot get at the result of any assingment, e.g.,

dsolve({eq, y(0) = 1, (D(y))(0) = -1}, numeric, events = [[y(x) = 0, [z = diff(y(x), x), halt]]]) does not work either; z does not have a value. What commands can be executed as actions after an event is triggered?





Please Wait...