I have the following function
$f(x) = \begin{cases} \sqrt{x} &\quad\forall \ x >= 0 \\ -\sqrt{-x} &\quad\forall \ x < 0 \end{cases}$
You can find a plot of the function here.
I'm using this function within an optimization problem. Since the "if" clause on the value of $x$ is necessary to determine which of the two functions needs to be applied, the problem becomes a binary optimization problem, which is computationally a lot more tedious to solve than a problem with continuous variables.
Therefore, I'd like to approximate the function with a continuous function. So far, I've played around with polynomial fits and Taylor functions, but nothing really approximated my function well, especially in the area around $x=0$.
Would anyone have a suggestion for me on how to tackle this problem? How can I find a continuous function, which is applicable for both positive and negative $x$, to approximate my function? Any suggestions would be appreciated!
Thanks.