Where is the mistake in this solution?
$$\sqrt{-i}=\sqrt {\cos \frac{3 \pi}2+i\sin \frac{3 \pi}2}=\cos \frac{3 \pi}4+i\sin \frac{3 \pi}4=-\frac{\sqrt 2}2+i \frac{\sqrt 2}2$$
WA gives me different result:
$$\frac{\sqrt 2}2-i \frac{\sqrt 2}2$$
Why the principal root must be equal to $\frac{\sqrt 2}2-i \frac{\sqrt 2}2$?
I used Moivre's formula. But I dont know. How can I must choose value of $k$ in Moivre's formula? I chose $k=0$.
$$z=r\left(\cos x+i\sin x\right)$$
$$z^{\frac 1n}=r^\frac1n \left( \cos \frac{x+2\pi k}{n} + i\sin \frac{x+2\pi k}{n}\right)$$
Technically, the problem is that the "principal root" is define using $z=r\left(\cos \theta +i\sin\theta\right)$ with $r>0$ and $\theta\in(-\pi,\pi].$ Then the principal $\sqrt{z}$ is defined as $\sqrt{r}\left(\cos \frac\theta 2 +i\sin\frac\theta 2\right).$
So in your case, we use $\theta=-\frac{\pi}{2},$ not $\frac{3\pi}{2}.$
The reason to define it this way is to make $\sqrt{z}$ continuous when $z$ is on the positive real line. Defining it for $\theta\in[0,2\pi)$ leaves $\sqrt{z}$ discontinuous at $z$ on the positive real line.
The "principal" value is a somewhat arbitrary definition. The principal value has the "branch cut" on the negative reals, but you could make your brach cut cut any simple path from $0$ to $\infty.$
You may learn in more advanced complex analysis that the proper way to define $\sqrt{z},$ to keep nice behavior, is to define it as a multi-valued function.