0
$\begingroup$
Piecewise[{{t^2, t <= 0}, {t, t >= 0}}]

Outputs:

t^2   t <= 0
t     t >= 0
0     True

What does the last line of output 0 True mean? Sometimes it also outputs Indeterminate etc. Can someone describe the behavior, constraints, and limitations of this function?

$\endgroup$
  • 1
    $\begingroup$ see Piecewise >> Details: (1) The Subscript[cond, i] are evaluated in turn, until one of them is found to yield True. _ (2) _If all preceding Subscript[cond, i] yield False, then the Subscript[val, i] corresponding to the first Subscript[cond, i] that yields True is returned as the value of the piecewise function. $\endgroup$ – kglr Mar 19 '15 at 11:15
  • 1
    $\begingroup$ .. (3) Piecewise[{{Subscript[val, 1],Subscript[cond, 1]}, ... },val] uses default value val if none of the Subscript[cond, i] apply. The default for val is 0. and (4) Piecewise[{{Subscript[val, 1],Subscript[cond, 1]},{Subscript[val, 2],Subscript[cond, 2]},...s]}] (i.e, single-argument form with no default value is supplied) uses 0 as the default default-value. $\endgroup$ – kglr Mar 19 '15 at 11:23
  • $\begingroup$ The function returns 0 if neither t >= 0 nor t <= 0. For example, if you define strange /: strange >= 0 = False; strange /: strange <= 0 = False you get a strange value which is neither >=0 nor <= 0. Consequently, if you evaluate your piecewise function with t=strange, you'll get 0 as result. $\endgroup$ – celtschk Mar 19 '15 at 16:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.