# Complex Piecewise function

**URL:** https://discourse.julialang.org/t/complex-piecewise-function/131681
**Category:** Modelling & Simulations
**Tags:** symbolics
**Created:** [August 18, 2025, 3:21pm UTC](https://discourse.julialang.org/t/complex-piecewise-function/131681 "2025-08-18T15:21:15Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Sergey\_Novak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sergey_novak/32/37716_2.png) [@Sergey\_Novak](https://discourse.julialang.org/u/Sergey_Novak)
#### Post date: [August 18, 2025, 3:21pm UTC](https://discourse.julialang.org/t/complex-piecewise-function/131681/1 "2025-08-18T15:21:15Z")

</div>

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

 ![image](https://global.discourse-cdn.com/julialang/original/3X/7/c/7c3fb0111156b80f7e4101dfe89a3bf3e0867368.png)

Thanks for your help

---

<div class="post-metadata">

### Author: ![yolhan\_mannes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yolhan_mannes/32/220485_2.png) [@yolhan\_mannes](https://discourse.julialang.org/u/yolhan_mannes)
#### Post date: [August 18, 2025, 3:48pm UTC](https://discourse.julialang.org/t/complex-piecewise-function/131681/2 "2025-08-18T15:48:06Z")

</div>

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

```julia-auto
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,α)

```
