I would like to show that, for $z \in \mathbb{C}$, $\sqrt{z^2}=\sqrt{x^2}+\frac{x}{|x|}yi$.
What I have is, for $z=x+yi$, where $x,y \in \mathbb{R}$,
$\sqrt{z^2}=z$ if $x>0$ or if $x=0$ and $y \geq 0$ OR $\sqrt{z^2}=-z$ if $x<0$ or if $x=0$ and $y<0$.
I also have $z^2=x^2-y^2+2xyi$.
The part that I’m having difficulty with is deriving the following equality, which is the last step I need to prove my initial equality:
$\sqrt{z^2}=\sqrt{x^2}+\frac{xy}{|xy|}\sqrt{y^2}i$.
Any suggestions?
Note: Recall that for a real number $x$, $\vert x\vert=\sqrt{x^2}$ and that for $x\ne0$, $\dfrac{x}{\vert x\vert}=\dfrac{\vert x\vert}{x}$.
Let $z=\vert z\vert(\cos\theta+i\sin\theta)$. Then $z^2=\vert z\vert^2(\cos2\theta+i\sin2\theta)$.
$z^2$ will have two square roots
$$ w=\pm(\vert z\vert(\cos\theta+i\sin\theta))=\pm(x+yi)$$
But the principle square root of a complex number is the root with non-negative real part. So
$$\sqrt{z^2}=\dfrac{x}{\vert x\vert}(x+yi)=\vert x\vert+\dfrac{x}{\vert x\vert}\cdot yi=\sqrt{x^2}+\dfrac{x}{\vert x\vert}\cdot yi$$