The documentation says

WhenEvent expressions can be used in NDSolve, NDSolveValue, ParametricNDSolve, ParametricNDSolveValue, DSolve, and DSolveValue.

But when I try this toy case


It complains that

Equation or list of equations expected instead of WhenEvent[f[t]==5,f[t]->10] in the first argument {f[0]==0,f'[t]==2,WhenEvent[f[t]==5,f[t]->10]}

But when I use this same eqn in NDSolve it works fine. So how do I get WhenEvent working with DSolve?


1 Answer 1


From the documentation of DSolve, this is classified as a hybrid-differential equation.

You need to specify the range of t something like {0, 10}

DSolve[{f[0] == 0, f'[t] == 2, WhenEvent[f[t] == 5, f[t] -> 10]}, f[t], {t, 0, 10}]

enter image description here

  • $\begingroup$ Well now when I look at the DSolve page that's obvious, I swear I checked that already... Thanks. They really should have a better error for that though. $\endgroup$
    – TrashGirl
    Feb 8, 2018 at 7:40

Your Answer

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

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