Complex Piecewise function

Hello,
Can I add this function using Symbolics.jl? I know about ifelse, but I haven’t found any examples with multiple conditions.

Thanks for your help

you can do how many ever you want, just use bitwize op

using Symbolics
function f(x,y,z,α)
     f1 = ifelse(x<=0,α/(1-x) + y,0.0)
     f2 = ifelse( (0<x) & (x<α) & (z<=0),α+y,0.0)
     f3 = ifelse((x>=α+y)|(z>0),-1.0,0.0)
     return f1+f2+f3
 end
@variables x,y,z,α
f(x,y,z,α)

1 Like