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 thex
notation 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 arraysx1
andx2
, respectively. Each element-wise result is expressed in radians.The mathematical signs of
x1_i
andx2_i
determine 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/x2
is defined forx2_i
equal to positive or negative zero and for either or both ofx1_i
andx2_i
equal to positive or negativeinfinity
.- Parameters:
x1 (array) – input array corresponding to the y-coordinates. Should have a real-valued floating-point data type.
x2 (array) – input array corresponding to the x-coordinates. Must be compatible with
x1
(see Broadcasting). Should have a real-valued floating-point data type.
- Returns:
out (array) – an array containing the inverse tangent of the quotient
x1/x2
. The returned array must have a real-valued floating-point data type determined by Type Promotion Rules.
Notes
Special cases
For floating-point operands,
If either
x1_i
orx2_i
isNaN
, the result isNaN
.If
x1_i
is greater than0
andx2_i
is+0
, the result is an implementation-dependent approximation to+π/2
.If
x1_i
is greater than0
andx2_i
is-0
, the result is an implementation-dependent approximation to+π/2
.If
x1_i
is+0
andx2_i
is greater than0
, the result is+0
.If
x1_i
is+0
andx2_i
is+0
, the result is+0
.If
x1_i
is+0
andx2_i
is-0
, the result is an implementation-dependent approximation to+π
.If
x1_i
is+0
andx2_i
is less than0
, the result is an implementation-dependent approximation to+π
.If
x1_i
is-0
andx2_i
is greater than0
, the result is-0
.If
x1_i
is-0
andx2_i
is+0
, the result is-0
.If
x1_i
is-0
andx2_i
is-0
, the result is an implementation-dependent approximation to-π
.If
x1_i
is-0
andx2_i
is less than0
, the result is an implementation-dependent approximation to-π
.If
x1_i
is less than0
andx2_i
is+0
, the result is an implementation-dependent approximation to-π/2
.If
x1_i
is less than0
andx2_i
is-0
, the result is an implementation-dependent approximation to-π/2
.If
x1_i
is greater than0
,x1_i
is a finite number, andx2_i
is+infinity
, the result is+0
.If
x1_i
is greater than0
,x1_i
is a finite number, andx2_i
is-infinity
, the result is an implementation-dependent approximation to+π
.If
x1_i
is less than0
,x1_i
is a finite number, andx2_i
is+infinity
, the result is-0
.If
x1_i
is less than0
,x1_i
is a finite number, andx2_i
is-infinity
, the result is an implementation-dependent approximation to-π
.If
x1_i
is+infinity
andx2_i
is a finite number, the result is an implementation-dependent approximation to+π/2
.If
x1_i
is-infinity
andx2_i
is a finite number, the result is an implementation-dependent approximation to-π/2
.If
x1_i
is+infinity
andx2_i
is+infinity
, the result is an implementation-dependent approximation to+π/4
.If
x1_i
is+infinity
andx2_i
is-infinity
, the result is an implementation-dependent approximation to+3π/4
.If
x1_i
is-infinity
andx2_i
is+infinity
, the result is an implementation-dependent approximation to-π/4
.If
x1_i
is-infinity
andx2_i
is-infinity
, the result is an implementation-dependent approximation to-3π/4
.