# MathLib.arctan2()

MathLib.arctan2 is an implementation of the arctan2 function: $\operatorname{MathLib.arctan2}(y, x) = -i \ln\left(\frac{x+iy}{\sqrt{x^2+y^2}}\right)$ The range of the result is $[ -\pi, \pi ]$

## Specification

MathLib.arctan2 is handling the special cases as defined by the IEEE 754-2008 standard:
1. MathLib.arctan2(±0, -0) = ±π
2. MathLib.arctan2(±0, +0) = ±0
3. MathLib.arctan2(±0, x) = ±π for x<0
4. MathLib.arctan2(±0, x) = ±0 for x>0
5. MathLib.arctan2(y, ±0) = -π/2 for y < 0
6. MathLib.arctan2(y, ±0) = +π/2 for y > 0
7. MathLib.arctan2(±y, -∞) = ±π for finite y > 0
8. MathLib.arctan2(±y, +∞) = ±0 for finite y > 0
9. MathLib.arctan2(±∞, x) = ±π/2 for finite x
10. MathLib.arctan2(±∞, -∞) = ±3π/4
11. MathLib.arctan2(±∞, +∞) = ±π/4
12. otherwise MathLib.arctan2(y, x) = $-i \ln\left(\frac{x+iy}{\sqrt{x^2+y^2}}\right)$

## Implementation

MathLib uses the built-in JavaScript implementation Math.atan2.

## Possible issues

Although 0 === -0 is true in JavaScript, formulas including these values don't have to be equal: $\text{MathLib.arctan2}(0, -1) = \pi \neq -\pi = \text{MathLib.arctan2}(-0, -1)$