add a new function called piecewise, which has 2*n +1 args and represents a piecewise mathematical function, for example
$$
f(x)=
\begin{cases}
x^2, & x \ge 0, \\
-x, & x < 0.
\end{cases}
$$
would be (last arg is a fallback in case all the expressions previously are false)
f { piecewise(x, x * x, -x - epsilon, -x, x * x) }
the first arg of piecewise is the check for x >= 0 and is similar to a heavyside function, the second arg is the value is the first arg is >= 0, the third arg is the check for x < 0, and the fourth arg is the value if the third arg is >= 0, the last arg is a fallback if none of the other checks are >=0
So the code would look through the n branches, if the check at arg 2i is >= 0, then the final value is the arg 2i + 1, otherwise the final value is the last arg.
add a new function called
piecewise, which has 2*n +1 args and represents a piecewise mathematical function, for examplewould be (last arg is a fallback in case all the expressions previously are false)
the first arg of piecewise is the check for x >= 0 and is similar to a heavyside function, the second arg is the value is the first arg is >= 0, the third arg is the check for x < 0, and the fourth arg is the value if the third arg is >= 0, the last arg is a fallback if none of the other checks are >=0
So the code would look through the n branches, if the check at arg 2i is >= 0, then the final value is the arg 2i + 1, otherwise the final value is the last arg.