0
$\begingroup$

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.

$\endgroup$
  • 1
    $\begingroup$ $f$ is a continuous function. $\endgroup$ – Lord Shark the Unknown Nov 8 '17 at 16:55
  • $\begingroup$ Note that the function's derivative goes to infinity as $x$ approaches zero. $\endgroup$ – hardmath Nov 8 '17 at 17:02
  • $\begingroup$ Ok, please let me rephrase that then: I'd like to approximate the aforementioned function without having any "cases", just one representation that applies for all x from minus infinity to plus infinity. Any suggestions? $\endgroup$ – P_E1 Nov 8 '17 at 17:11
  • $\begingroup$ Perhaps $(x/|x|)\sqrt{|x|},$ with some care when evaluating exactly at $0$? $\endgroup$ – RideTheWavelet Nov 8 '17 at 17:48
  • 2
    $\begingroup$ $sign(x) \sqrt{|x|}$ or $\frac{x}{\sqrt{|x|}}$ $\endgroup$ – MotiN Nov 8 '17 at 17:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.