How to express in closed form?

How to express this function in closed form without condition verfication and Re and Im functions (only with absolute value function)?

$$f(z)= \begin{cases} - \operatorname{sgn}(\operatorname{Im}(z)), & \mbox{if } \operatorname{Re}(x)=0 \\ \operatorname{sgn}(\operatorname{Re}(z)), & \mbox{if } \operatorname{Re}(x)\ne 0 \end{cases}$$

-
Is this a question, or a puzzle? If the former, why the arbitrary restriction? If you must have a one-line formula for this, you could do it using indicator functions, for example... – Zhen Lin Mar 22 '11 at 13:31
Yes, I want a one-line formula. – Anixx Mar 22 '11 at 13:36

Does ${\rm sgn}(x) = 0$ if $x = 0$? If so, then using Zhen's indicator function idea and simplifying,

$$f(z) = {\rm sgn}({\rm Re}(z)) - {\rm sgn}({\rm Im}(z)) (1-{\rm sgn}({\rm Re}(z))^2)$$

But you may find that with $\rm sgn$ any sort of derivation you'll probably want to split up into cases that are already conveniently split up. That is, even though at first the definition by cases seems more obscure and not 'closed form', it may in the end be easier to manipulate in the 'by cases' form.

('closed form' has many interpretations, and 'by cases' can fall on either side)

-
Thank you. It seems this expression can be expressed without Im and Re. – Anixx Mar 22 '11 at 19:22
@Anixx: Yes, I forgot about that. $Re(z) = \frac{z+\bar{z}}{2}$ and $Im(z) = \frac{z-\bar{z}}{2}$. But then you may also want to remove $\bar{z}$, which can be done with exponential's and trig. At this point you're getting pretty messy, and you still have no way of removing 'sgn' nicely (see Eelvex's comment) because at the places where $x\over |x|$ is undefined is exactly where you have special cases in your function. So the exercise to convert to 'elementary' functions might be interesting, but I don't think it is immediately useful. – Mitch Mar 23 '11 at 0:16
@Annix: I have since learned that I was wrong that $\bar{z}$ can be done 'closed' form with exponentials and trig (meaning 'elementary functions') See: math.stackexchange.com/questions/28594/… . But my point still stands: sometimes closed form is a good thing, but sometimes it just obfuscates what is going on (where a case analysis, despite felling clunky, would still be more ... instructive) – Mitch Mar 29 '11 at 18:03

One way would be:

$$f(z) = -\operatorname{sgn}(-iz)(1-g(x)) + \operatorname{sgn}(\frac{z+\bar{z}}{2})g(x)$$

where

$$g(x) = |\operatorname{sgn}(\frac{z+\bar{z}}{2})|$$

Or:

$$f(z) = \operatorname{sgn}(iz)(1-|\operatorname{sgn}(\frac{z+\bar{z}}{2})|) + \operatorname{sgn}(\frac{z+\bar{z}}{2})$$

-
Is the sgn(iz), i.e of an imaginable value defined somehow? – Anixx Mar 22 '11 at 19:18
@Anixx: you can't express $\rm{sgn}$ without using some step function unless you know that $z\neq 0$. In that case $\rm{sgn}(z) = \frac{z}{|z|}$. – Eelvex Mar 22 '11 at 19:45