Timeline for Why can't I use logic operator Or to specify multiple events with WhenEvent?
Current License: CC BY-SA 4.0
10 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Feb 19 at 15:53 | history | edited | xzczd♦ | CC BY-SA 4.0 |
added 4 characters in body
|
Feb 19 at 15:46 | history | edited | xzczd♦ | CC BY-SA 4.0 |
added 1537 characters in body
|
Feb 19 at 10:21 | vote | accept | xinxin guo | ||
Feb 19 at 10:21 | comment | added | xinxin guo | Thanks! Very helpful! | |
Feb 19 at 10:03 | comment | added | xzczd♦ |
@xinxin "Do they also pose similar misleading issues?" No, AFAIK,currently only conditions in the first table in Details and Options i.e. f==0 , f>0 , f<0 , Mod[…]==0 and And are analyzed in special manner, other conditions are all treated as general conditions. You can simply consider them as black box functions that output True or False .
|
|
Feb 19 at 9:56 | comment | added | xinxin guo |
Thanks. The following conclusion in the post you give is very crucial. "As an event in WhenEvent[], A && B is not logically equivalent to "A AND B"; rather, it is equivalent to "A IF B."" And Michael E2 suggested hiding the And operator using a function. I would like to ask: What about other logical operators (Or , Not , etc.)? Do they also pose similar misleading issues? How to use logical operators to define a general condition for event occurrence?
|
|
Feb 19 at 9:46 | comment | added | xzczd♦ | @xinxin If you find the document too brief, see also the first section of the answer you've found: mathematica.stackexchange.com/a/154560/1871 In short, if the event is of special forms listed in document, it'll be analyzed in a cleverer way. | |
Feb 19 at 9:44 | comment | added | xinxin guo |
Yeah, I find your comment on the attribute HoldAll of WhenEvent in the link you give. It explains a lot. Thanks!
|
|
Feb 19 at 9:38 | comment | added | xinxin guo | Thanks! I have to read the software documentation several times almost every time I use the WhenEvent command. I carefully reread the "Details and Options" section, but I didn't find anything new. The article only mentioned cases like f>0 && pred, which is quite understandable, but forgive my dullness, I still can't understand the statement you made, "And defining the condition as a general condition involving || will stop NDSolve from analyzing the condition." Could you please explain this statement in more details? Thank you. | |
Feb 19 at 8:27 | history | answered | xzczd♦ | CC BY-SA 4.0 |