Skip to main content

Timeline for Bug in NDSolve/WhenEvent?

Current License: CC BY-SA 3.0

5 events
when toggle format what by license comment
Jun 13, 2016 at 16:42 history edited Feyre CC BY-SA 3.0
Corrected now working answer.
Jun 13, 2016 at 16:39 comment added Feyre @MichaelE2 And apparently similarly {sol} = NDSolve[{x'[t] == -0.08 x[t], x[0] == 1., WhenEvent[Norm[{x'[t]}] < 0.0001, x[t] -> 1.; x[t] -> 1]}, {x}, {t, 0, 200}] Works fine. Now also allowing plotting of velocity.
Jun 13, 2016 at 16:30 comment added Michael E2 But x'[t] does seem to be available in this similar code: NDSolve[{x'[t] == Sin[t], x[0] == 1, WhenEvent[x'[t] < 0, Null; x[t] -> 3 - x[t]]}, x, {t, 0, 20}]. Similarly it is used here, albeit in the pre-WhenEvent days, to locate all local extrema. -- During integration, the value of x'[t] is one of the "SolutionDataComponents" and can be used in the event (but not the action, I think) of a WhenEvent call. See Components and Data Structures for more.
Jun 13, 2016 at 16:12 history edited Feyre CC BY-SA 3.0
Expanded answer
Jun 13, 2016 at 16:01 history answered Feyre CC BY-SA 3.0