Re: Piecewise vs. /; ?

*To*: mathgroup at smc.vnet.net*Subject*: [mg104016] Re: Piecewise vs. /; ?*From*: Dan Dubin <ddubin at ucsd.edu>*Date*: Thu, 15 Oct 2009 07:19:33 -0400 (EDT)*References*: <hashpc$qu8$1@smc.vnet.net> <hav19a$4gr$1@smc.vnet.net>

Folks -- I would respectfully disagree with the idea that /; is more general than Piecewise. The example given, a function that returns a different value in the morning than the evening, is simply a time-dependent function that could be constructed using Piecewise, as in f[x_,h_] = Piecewise[{{x, h < 12}, {-x, h >= 12}}]; and called via f[x,DateList[[4]]] In fact, it seems to me that any difference in the way that Mathematica interprets Piecewise and conditionals should be removed from later editions of Mathematica, since as far as I can see the difference between them is merely a Mathematica-specific matter of the mechanics of how the expressions are evaluated with little (or no?) utility, that causes considerable confusion among new users. I don't see any benefit in this distinction, but feel free to convince me otherwise! >Szabolcs Horv=E1t wrote: >> In short, /; is a programming construct that affects evaluation. >> Piecewise[] is used to represent a mathematical concept: piecewise >> functions. >> >> If you want to do mathematical operations like integration, then use >> Piecewise[]. Condition[] (/;) is a lot more general than Piecewise[], >> for example one could write a "function" that returns a different value >> in the evening than in the morning, which is obviously not a function in >> the mathematical sense, and thus can't be integrated. > >Got it! Thanks to you and David for responding. > >-- >Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/ > San Jose, CA, USA && 37 18 N 121 57 W && AIM/Y!M/Skype erikmaxfrancis > God is love, but get it in writing. > -- Gypsy Rose Lee --

**Follow-Ups**:**Re: Piecewise vs. /; ?***From:*Daniel Lichtblau <danl@wolfram.com>