<s>[INST] How to calculate this imaginary part of a complex square root? The calculation of the square root of a complex number $a + ib$ involves solving the equation
$$ (x + iy)^2 = a + ib$$
So far so good. One obtains the equations 
$$ 4x^4 -4ax^2 - b^2 = 0, y = b/2x$$
and using the quadratic formula for $x^2$ one gets
$$ x = \pm \sqrt{{a + \sqrt{a^2 + b^2} \over 2}}$$
I am supposed to get
$$ y = \pm \sqrt{- a + \sqrt{a^2 + b^2} \over 2} \cdot \text{sgn}(b)$$
but if I substitute $x$ into $y$ I get
$$ y = {b\over 2x} = \pm {b \sqrt{2} \over 2\sqrt{a + \sqrt{a^2 + b^2}}}$$

What am I doing wrong?

 [/INST] *

*When $\text{a}\space\wedge\space\text{b}\in\mathbb{C}$:
$$\text{a}=\text{b}^2=\left(\Re[\text{b}]+\Im[\text{b}]i\right)^2=\Re^2[\text{b}]-\Im^2[\text{b}]+2\Re[\text{b}]\Im[\text{b}i]$$

*Solving $x$:
$$y=\frac{\text{b}}{2x}\Longleftrightarrow\text{b}=2xy\Longleftrightarrow x=\frac{\text{b}}{2y}$$

*Solving $x$ by substituting $y=x^2$:
$$4x^4-4\text{a}x^2-\text{b}^2=0\Longleftrightarrow y=\frac{\text{a}\pm\sqrt{\text{a}^2+\text{b}^2}}{2}\Longleftrightarrow x=\color{red}{\pm}\frac{\sqrt{\text{a}\color{red}{\pm}\sqrt{\text{a}^2+\text{b}^2}}}{\sqrt{2}}$$


So for (3) we find 4 solutions.
And for $\text{sgn}(\text{z})$, when $\text{z}\in\mathbb{C}$ (and $\text{z}\ne0$):
$$\text{sgn}(\text{z})=\frac{\text{z}}{\sqrt{\text{z}\cdot\overline{\text{z}}}}=\frac{\text{z}}{\sqrt{|\text{z}|^2}}=\frac{\text{z}}{|\text{z}|}$$
</s>