DARCTAN2 Function

DARCTAN2 accepts any two numbers x and y and returns the arctangent of the quotient of those two numbers.

DARCTAN2 is defined for all real x and y values. This function is adapted to fall in the range of -pi through +pi by choosing it in a quadrant determined by the signs of x and y. In effect, this function is used in complex arithmetic as follows: given the complex number x + iy, DARCTAN2 (x,y) returns the argument of that number between -pi and pi.

DARCTAN2 is calculated from the DARCTAN function as follows:

  • If y is equal to 0, then

    DARCTAN2(x,0) = sign(x)*pi/2
  • If y is less than 0, then

    DARCTAN2(x,y) = DARCTAN(x/y) + sign(x)*pi 
  • If y is greater than 0, then

    DARCTAN2(x,y) = DARCTAN(x/y) 

In these calculations, sign(x) is a function that has the value +1 if x is greater than or equal to 0, otherwise the value is -1.