Skip to main content
8 events
when toggle format what by license comment
May 20, 2018 at 16:25 comment added John Doty @becko: Mathematica is not a programming language in the usual sense. It is an expression rewriting system. Some rewrite rules behave like programming constructs, so using If is like programming. However, in symbolic analysis, If is too undisciplined to be deconstructed abstractly. Piecewise has the necessary discipline for symbolic analysis, so the rewrite rules behind things like Integrate can manage to rewrite it without evaluating it. If needs to be evaluated before symbolic rules can safely rewrite it.
Nov 27, 2017 at 12:34 comment added Szabolcs @becko I sympathise with your general feeling.
Nov 27, 2017 at 11:19 comment added a06e +1 Before accepting your answer I'll wait a bit in case someone else can come up with a "theory of everything", if it exists.
Nov 27, 2017 at 11:16 comment added a06e I see the difficulty. This is the thing I dislike the most about Mathematica. You cannot summarize its syntax in a few simple rules. Other languages prioritize simplicity, so that understanding the rules and predicting execution behavior is relatively easy. But Mathematica instead prioritizes having these all powerful functions, which are very handy most of the time, but when you try to understand how they work, or when something does not execute like you thought it would, it's a pain.
Nov 27, 2017 at 10:10 comment added Szabolcs @becko Note that it isn't even sufficient to look at how each evaluates. You'd also need to look at how other functions (like D above) handle them. That makes listing all differences an impossibly difficult task. Does Simplify, Refine, etc. handle Which? I'm sure there will be some functions which only handle Piecewise and not Which. You'd have to go through all symbolic functions ...
Nov 27, 2017 at 10:08 comment added Szabolcs @becko I didn't attempt to meticulously discover all specific differences. But the intended use is clear. So if you were instead asking: "which should I use?", I would suggest deciding based on what I described above.
Nov 27, 2017 at 10:00 comment added a06e Can we understand all the differences between Piecewise and Which, just from the fact that one evaluates its arguments and the other doesn't?
Nov 27, 2017 at 8:17 history answered Szabolcs CC BY-SA 3.0