User:Beornas/sandbox

Principal value
The principal value of the argument of the complex number x+iy is given by:

\operatorname{arg}(x+iy)=2 \arctan \frac{y}{\sqrt{x^2+y^2}+x}. $$

or the simpler:

\operatorname{arg}(x+iy)= \arctan \frac{y}{x}. $$ (+π if a<0)

It is π on the negative x axis and undefined at 0.

This produces results in the range (&minus;π, π]. It can be mapped to [ 0, 2π ) by adding 2π to negative values.

This is equivalent to atan2(y, x), an alternative definition more suited for numeric computation is given in that article. The atan2 function is normally available in programming language libraries even if the complex argument function is not. Implementations returning a numeric value normally return a finite value for atan2(0, 0) in the range [-π,π] rather than being undefined.