User:Svjo/sandbox

Derivation of $atan2(y, x)$
The derivation of the principal value of the argument:
 * $$\text{If}\ (x,\,y) = (r \cos\theta, r \sin\theta)\ \text{then}\ \tan\cfrac{\theta}{2} = \cfrac{y}{r + x}$$

It follows that
 * $$\arg(x,y)=\theta=2{\theta\over2}=2\arctan{y\over\sqrt{x^2+y^2}+x}\ .$$

Note that $√x2 + y2 + x ≠ 0$ in the domain in question. Computation gives
 * $$\nabla\arg(x,y)=\left({-y\over x^2+y^2}, \ {x\over x^2+y^2}\right)\ .$$