piecewise function
Cases written value if condition, with an optional otherwise case.
How to write it
piecewise(case, ...)
The first case whose condition holds; end with value otherwise.
- case
- A value and the condition it holds under, written value if condition. Takes a value with its condition.
Examples
subs(piecewise(x if x > 0, -x otherwise), x -> -3)In the solver,
Open in the solversubs(piecewise(x if x > 0, -x otherwise), x -> -3)gives3.
Functions its examples use
- subs
Substitute a rule, or a list of rules, in an expression.
Related functions
- pre_decrement
Subtract 1 from a variable in place and return the new value.
- indicator
A condition as a number: 1 when it is true and 0 when it is false.
- pre_increment
Add 1 to a variable in place and return the new value.
- increment
Add 1 to a variable in place and return its old value.
- release_hold
Evaluate an expression that was held.
- ifelse
A value chosen by a test.