I have struggled a lot lately with the combination of NDSolve and WhenEvents. At this point I think it must be a bug of some sort.

I solve a differential equation with NDSolve, using WhenEvents to detect “impacts”, i.e., time instants when θ(t)==0. At that time instant, I want to reduce θ'(t) by multiplying it by, say, 0.5.

Here’s an example:

```
α = 10 π/180; p = 1.4; αp = 5 g Tan(α); g = 9.81; tmax = 1;
Eq = θ''(t) +
p^2 (Sin(α Sign(θ(t)) - θ(t)) +
αp (Sin(1 t) - Cos(8 t))/g Cos(α Sign(θ(t)) - θ(t))) == 0;
s = NDSolve({Eq, θ(0) == 0, θ'(0) == 0,
WhenEvent(θ(t) == 0, {Print(t), θ'(t) -> 0.5 θ'(t)},
"DetectionMethod" -> "Interpolation")}, θ, {t, 0, 1});
```

When I run the code, it detects an impact successfully (as t is printed), around 0.43 seconds:

Yet the derivative is not changed. If I plot θ'(t), it shows that “something” happens to θ'(t), like a change in its slope, but there is no step change as I would expect.

If I change the code into:

```
s = NDSolve({Eq, θ(0) == 0, θ'(0) == 0,
WhenEvent(θ(t) == 0.000001, {Print(t), θ'(t) -> 0.5 θ'(t)},
"DetectionMethod" -> "Interpolation")}, θ, {t, 0, 1});
```

i.e., when I change θ(t) == 0 into θ(t) == 0.000001, within the WhenEvent, then the change in derivative works:

I have experienced similar problems with other excitation functions instead of αp (Sin(1 t) – Cos(8 t))/g, which is just an example. Sometimes even if I put 0.000001 in the event, the derivative sometimes changes, sometimes doesn’t. I have tried all “detection method” options too.

Any ideas?

TIA