<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] First off, up to a sign (reflected by that $\mbox{sgn }(b)$ factor), the two expressions are equal. You can see this if you multiply the expression you got by 
$$
\frac{\sqrt{\sqrt{a^2+b^2}-a}}{\sqrt{\sqrt{a^2+b^2}-a}}
$$
to get
$$
y = \pm \frac{b}{\sqrt{b^2}} \frac{\sqrt{\sqrt{a^2+b^2}-a}}{\sqrt{2}}
$$
And of course, since all use of the square root symbol implies the positive square root, 
$$
\frac{b}{\sqrt{b^2}} = \mbox{sgn }(b)
$$
That is, you did everything right, except not trusting your answer.
</s>