atan2¶
- atan2(x1: array, x2: array, /) array¶
Calculates an implementation-dependent approximation of the inverse tangent of the quotient
x1/x2, having domain[-infinity, +infinity] x [-infinity, +infinity](where thexnotation denotes the set of ordered pairs of elements(x1_i, x2_i)) and codomain[-π, +π], for each pair of elements(x1_i, x2_i)of the input arraysx1andx2, respectively. Each element-wise result is expressed in radians.The mathematical signs of
x1_iandx2_idetermine the quadrant of each element-wise result. The quadrant (i.e., branch) is chosen such that each element-wise result is the signed angle in radians between the ray ending at the origin and passing through the point(1,0)and the ray ending at the origin and passing through the point(x2_i, x1_i).Note
Note the role reversal: the “y-coordinate” is the first function parameter; the “x-coordinate” is the second function parameter. The parameter order is intentional and traditional for the two-argument inverse tangent function where the y-coordinate argument is first and the x-coordinate argument is second.
By IEEE 754 convention, the inverse tangent of the quotient
x1/x2is defined forx2_iequal to positive or negative zero and for either or both ofx1_iandx2_iequal to positive or negativeinfinity.Special cases
For floating-point operands,
If either
x1_iorx2_iisNaN, the result isNaN.If
x1_iis greater than0andx2_iis+0, the result is an implementation-dependent approximation to+π/2.If
x1_iis greater than0andx2_iis-0, the result is an implementation-dependent approximation to+π/2.If
x1_iis+0andx2_iis greater than0, the result is+0.If
x1_iis+0andx2_iis+0, the result is+0.If
x1_iis+0andx2_iis-0, the result is an implementation-dependent approximation to+π.If
x1_iis+0andx2_iis less than0, the result is an implementation-dependent approximation to+π.If
x1_iis-0andx2_iis greater than0, the result is-0.If
x1_iis-0andx2_iis+0, the result is-0.If
x1_iis-0andx2_iis-0, the result is an implementation-dependent approximation to-π.If
x1_iis-0andx2_iis less than0, the result is an implementation-dependent approximation to-π.If
x1_iis less than0andx2_iis+0, the result is an implementation-dependent approximation to-π/2.If
x1_iis less than0andx2_iis-0, the result is an implementation-dependent approximation to-π/2.If
x1_iis greater than0,x1_iis a finite number, andx2_iis+infinity, the result is+0.If
x1_iis greater than0,x1_iis a finite number, andx2_iis-infinity, the result is an implementation-dependent approximation to+π.If
x1_iis less than0,x1_iis a finite number, andx2_iis+infinity, the result is-0.If
x1_iis less than0,x1_iis a finite number, andx2_iis-infinity, the result is an implementation-dependent approximation to-π.If
x1_iis+infinityandx2_iis finite, the result is an implementation-dependent approximation to+π/2.If
x1_iis-infinityandx2_iis finite, the result is an implementation-dependent approximation to-π/2.If
x1_iis+infinityandx2_iis+infinity, the result is an implementation-dependent approximation to+π/4.If
x1_iis+infinityandx2_iis-infinity, the result is an implementation-dependent approximation to+3π/4.If
x1_iis-infinityandx2_iis+infinity, the result is an implementation-dependent approximation to-π/4.If
x1_iis-infinityandx2_iis-infinity, the result is an implementation-dependent approximation to-3π/4.
- Parameters:
x1 (array) – input array corresponding to the y-coordinates. Should have a floating-point data type.
x2 (array) – input array corresponding to the x-coordinates. Must be compatible with
x1(see Broadcasting). Should have a floating-point data type.
- Returns:
out (array) – an array containing the inverse tangent of the quotient
x1/x2. The returned array must have a floating-point data type determined by Type Promotion Rules.