Skip to content

Commit 57d60ce

Browse files
authored
Add complex number support to atan (#523)
1 parent dc98c25 commit 57d60ce

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

spec/API_specification/array_api/elementwise_functions.py

+25-5
Original file line numberDiff line numberDiff line change
@@ -167,28 +167,48 @@ def asinh(x: array, /) -> array:
167167
"""
168168

169169
def atan(x: array, /) -> array:
170-
"""
171-
Calculates an implementation-dependent approximation of the principal value of the inverse tangent, having domain ``[-infinity, +infinity]`` and codomain ``[-π/2, +π/2]``, for each element ``x_i`` of the input array ``x``. Each element-wise result is expressed in radians.
170+
r"""
171+
Calculates an implementation-dependent approximation of the principal value of the inverse tangent for each element ``x_i`` of the input array ``x``.
172+
173+
Each element-wise result is expressed in radians.
172174
173175
**Special cases**
174176
175-
For floating-point operands,
177+
For real-valued floating-point operands,
176178
177179
- If ``x_i`` is ``NaN``, the result is ``NaN``.
178180
- If ``x_i`` is ``+0``, the result is ``+0``.
179181
- If ``x_i`` is ``-0``, the result is ``-0``.
180182
- If ``x_i`` is ``+infinity``, the result is an implementation-dependent approximation to ``+π/2``.
181183
- If ``x_i`` is ``-infinity``, the result is an implementation-dependent approximation to ``-π/2``.
182184
185+
For complex floating-point operands, special cases must be handled as if the operation is implemented as ``-1j * atanh(x*1j)``.
186+
187+
.. note::
188+
The principal value of the inverse tangent of a complex number :math:`z` is
189+
190+
.. math::
191+
\operatorname{atan}(z) = -\frac{\ln(1 - zj) - \ln(1 + zj)}{2}j
192+
193+
.. note::
194+
For complex floating-point operands, ``atan(conj(x))`` must equal ``conj(atan(x))``.
195+
196+
.. note::
197+
The inverse tangent (or arc tangent) is a multi-valued function and requires a branch on the complex plane. By convention, a branch cut is placed at the line segments :math:`(-\infty j, -j)` and :math:`(+j, \infty j)` of the imaginary axis.
198+
199+
Accordingly, for complex arguments, the function returns the inverse tangent in the range of a strip unbounded along the imaginary axis and in the interval :math:`[-\pi/2, +\pi/2]` along the real axis.
200+
201+
*Note: branch cuts have provisional status* (see :ref:`branch-cuts`).
202+
183203
Parameters
184204
----------
185205
x: array
186-
input array. Should have a real-valued floating-point data type.
206+
input array. Should have a floating-point data type.
187207
188208
Returns
189209
-------
190210
out: array
191-
an array containing the inverse tangent of each element in ``x``. The returned array must have a real-valued floating-point data type determined by :ref:`type-promotion`.
211+
an array containing the inverse tangent of each element in ``x``. The returned array must have a floating-point data type determined by :ref:`type-promotion`.
192212
"""
193213

194214
def atan2(x1: array, x2: array, /) -> array:

0 commit comments

Comments
 (0)