Skip to content

Commit c1fbd4d

Browse files
authored
Add complex support to asinh (#522)
1 parent b5e6af0 commit c1fbd4d

File tree

1 file changed

+38
-5
lines changed

1 file changed

+38
-5
lines changed

spec/API_specification/array_api/elementwise_functions.py

+38-5
Original file line numberDiff line numberDiff line change
@@ -142,28 +142,61 @@ def asin(x: array, /) -> array:
142142
"""
143143

144144
def asinh(x: array, /) -> array:
145-
"""
146-
Calculates an implementation-dependent approximation to the inverse hyperbolic sine, having domain ``[-infinity, +infinity]`` and codomain ``[-infinity, +infinity]``, for each element ``x_i`` in the input array ``x``.
145+
r"""
146+
Calculates an implementation-dependent approximation to the inverse hyperbolic sine for each element ``x_i`` in the input array ``x``.
147147
148148
**Special cases**
149149
150-
For floating-point operands,
150+
For real-valued floating-point operands,
151151
152152
- If ``x_i`` is ``NaN``, the result is ``NaN``.
153153
- If ``x_i`` is ``+0``, the result is ``+0``.
154154
- If ``x_i`` is ``-0``, the result is ``-0``.
155155
- If ``x_i`` is ``+infinity``, the result is ``+infinity``.
156156
- If ``x_i`` is ``-infinity``, the result is ``-infinity``.
157157
158+
For complex floating-point operands, let ``a = real(x_i)``, ``b = imag(x_i)``, and
159+
160+
- If ``a`` is ``+0`` and ``b`` is ``+0``, the result is ``+0 + 0j``.
161+
- If ``a`` is a positive (i.e., greater than ``0``) finite number and ``b`` is ``+infinity``, the result is ``+infinity + πj/2``.
162+
- If ``a`` is a finite number and ``b`` is ``NaN``, the result is ``NaN + NaN j``.
163+
- If ``a`` is ``+infinity`` and ``b`` is a positive (i.e., greater than ``0``) finite number, the result is ``+infinity + 0j``.
164+
- If ``a`` is ``+infinity`` and ``b`` is ``+infinity``, the result is ``+infinity + πj/4``.
165+
- If ``a`` is ``NaN`` and ``b`` is ``+0``, the result is ``NaN + 0j``.
166+
- If ``a`` is ``NaN`` and ``b`` is a nonzero finite number, the result is ``NaN + NaN j``.
167+
- If ``a`` is ``NaN`` and ``b`` is ``+infinity``, the result is ``±infinity + NaN j`` (sign of the real component is unspecified).
168+
- If ``a`` is ``NaN`` and ``b`` is ``NaN``, the result is ``NaN + NaN j``.
169+
170+
.. note::
171+
The principal value of the inverse hyperbolic sine of a complex number :math:`z` is
172+
173+
.. math::
174+
\operatorname{asinh}(z) = \ln(z + \sqrt{1+z^2})
175+
176+
For any :math:`z`,
177+
178+
.. math::
179+
\operatorname{asinh}(z) = \frac{\operatorname{asin}(zj)}{j}
180+
181+
.. note::
182+
For complex floating-point operands, ``asinh(conj(x))`` must equal ``conj(asinh(x))`` and ``asinh(-z)`` must equal ``-asinh(z)``.
183+
184+
.. note::
185+
The inverse hyperbolic sine is a multi-valued function and requires a branch cut 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.
186+
187+
Accordingly, for complex arguments, the function returns the inverse hyperbolic sine in the range of a strip unbounded along the real axis and in the interval :math:`[-\pi j/2, +\pi j/2]` along the imaginary axis.
188+
189+
*Note: branch cuts have provisional status* (see :ref:`branch-cuts`).
190+
158191
Parameters
159192
----------
160193
x: array
161-
input array whose elements each represent the area of a hyperbolic sector. Should have a real-valued floating-point data type.
194+
input array whose elements each represent the area of a hyperbolic sector. Should have a floating-point data type.
162195
163196
Returns
164197
-------
165198
out: array
166-
an array containing the inverse hyperbolic sine of each element in ``x``. The returned array must have a real-valued floating-point data type determined by :ref:`type-promotion`.
199+
an array containing the inverse hyperbolic sine of each element in ``x``. The returned array must have a floating-point data type determined by :ref:`type-promotion`.
167200
"""
168201

169202
def atan(x: array, /) -> array:

0 commit comments

Comments
 (0)