13
$\begingroup$

Bug introduced in 9.0 and fixed in 11.0.0

WhenEvent is new in 9.0.


This is an example from the docs, slightly modified (action is wrapped in { }), working as expected.

NDSolve[{x'[t] == x[t], x[0] == 1, 
  WhenEvent[Mod[t, 1] == 0, {x[t] -> x[t] + (-1)^t}]}, x, {t, 0, 3}]
  {{x -> InterpolatingFunction[{{0., 3.}}, <>]}}

When the action is deliberately removed (because for example the action is programmatically generated for a list of variables that can be empty), it crashes the kernel.

Warning: the following line might crash the kernel. Save your work.

NDSolve[{x'[t] == x[t], x[0] == 1, 
  WhenEvent[Mod[t, 1] == 0, {(*x[t] -> x[t] + (-1)^t*)}]}, x, {t, 0, 3}]

Can anyone reproduce this?

(Mathematica 10.4.0 for Microsoft Windows (Win7, 64-bit))

$\endgroup$
2
  • 3
    $\begingroup$ Confirmed on OS X 10.11.4, M 10.4.1, M 10.3.1, M 10.0.2 and M 9.0.1. All of them crash. $\endgroup$
    – Szabolcs
    May 4, 2016 at 12:06
  • 7
    $\begingroup$ Thanks a lot @Szabolcs, submitting to TechSupport. I've found more bugs in the last month than in the last 10 years of using Mathematica. It's like crossing a threshold after which one cannot really be productive due to seeing bugs everyewhere. They are swarming... $\endgroup$ May 4, 2016 at 12:16

1 Answer 1

4
$\begingroup$

TechSupport acknowledged and proposed a simple workaround by putting inert expression, e.g. empty string, inside the { }:

NDSolve[{x'[t] == x[t], x[0] == 1, WhenEvent[Mod[t, 1] == 0, {""}]}, x, {t, 0, 3}]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.