Skip to content

Commit f32ec6b

Browse files
authored
Add complex support to acosh (#520)
1 parent 1d1833f commit f32ec6b

File tree

1 file changed

+48
-5
lines changed

1 file changed

+48
-5
lines changed

spec/API_specification/array_api/elementwise_functions.py

+48-5
Original file line numberDiff line numberDiff line change
@@ -51,27 +51,70 @@ def acos(x: array, /) -> array:
5151
"""
5252

5353
def acosh(x: array, /) -> array:
54-
"""
55-
Calculates an implementation-dependent approximation to the inverse hyperbolic cosine, having domain ``[+1, +infinity]`` and codomain ``[+0, +infinity]``, for each element ``x_i`` of the input array ``x``.
54+
r"""
55+
Calculates an implementation-dependent approximation to the inverse hyperbolic cosine for each element ``x_i`` of the input array ``x``.
5656
5757
**Special cases**
5858
59-
For floating-point operands,
59+
For real-valued floating-point operands,
6060
6161
- If ``x_i`` is ``NaN``, the result is ``NaN``.
6262
- If ``x_i`` is less than ``1``, the result is ``NaN``.
6363
- If ``x_i`` is ``1``, the result is ``+0``.
6464
- If ``x_i`` is ``+infinity``, the result is ``+infinity``.
6565
66+
For complex floating-point operands, let ``a = real(x_i)``, ``b = imag(x_i)``, and
67+
68+
- If ``a`` is either ``+0`` or ``-0`` and ``b`` is ``+0``, the result is ``+0 + πj/2``.
69+
- If ``a`` is a finite number and ``b`` is ``+infinity``, the result is ``+infinity + πj/2``.
70+
- If ``a`` is a nonzero finite number and ``b`` is ``NaN``, the result is ``NaN + NaN j``.
71+
- If ``a`` is ``+0`` and ``b`` is ``NaN``, the result is ``NaN ± πj/2`` (sign of imaginary component is unspecified).
72+
- If ``a`` is ``-infinity`` and ``b`` is a positive (i.e., greater than ``0``) finite number, the result is ``+infinity + πj``.
73+
- If ``a`` is ``+infinity`` and ``b`` is a positive (i.e., greater than ``0``) finite number, the result is ``+infinity + 0j``.
74+
- If ``a`` is ``-infinity`` and ``b`` is ``+infinity``, the result is ``+infinity + 3πj/4``.
75+
- If ``a`` is ``+infinity`` and ``b`` is ``+infinity``, the result is ``+infinity + πj/4``.
76+
- If ``a`` is either ``+infinity`` or ``-infinity`` and ``b`` is ``NaN``, the result is ``+infinity + NaN j``.
77+
- If ``a`` is ``NaN`` and ``b`` is a finite number, the result is ``NaN + NaN j``.
78+
- If ``a`` is ``NaN`` and ``b`` is ``+infinity``, the result is ``+infinity + NaN j``.
79+
- If ``a`` is ``NaN`` and ``b`` is ``NaN``, the result is ``NaN + NaN j``.
80+
81+
.. note::
82+
The principal value of the inverse hyperbolic cosine of a complex number :math:`z` is
83+
84+
.. math::
85+
\operatorname{acosh}(z) = \ln(z + \sqrt{z+1}\sqrt{z-1})
86+
87+
For any :math:`z`,
88+
89+
.. math::
90+
\operatorname{acosh}(z) = \frac{\sqrt{z-1}}{\sqrt{1-z}}\operatorname{acos}(z)
91+
92+
or simply
93+
94+
.. math::
95+
\operatorname{acosh}(z) = j\ \operatorname{acos}(z)
96+
97+
in the upper half of the complex plane.
98+
99+
.. note::
100+
For complex floating-point operands, ``acosh(conj(x))`` must equal ``conj(acosh(x))``.
101+
102+
.. note::
103+
The inverse hyperbolic cosine is a multi-valued function and requires a branch cut on the complex plane. By convention, a branch cut is placed at the line segment :math:`(-\infty, 1)` of the real axis.
104+
105+
Accordingly, for complex arguments, the function returns the inverse hyperbolic cosine in the interval :math:`[0, \infty)` along the real axis and in the interval :math:`[-\pi j, +\pi j]` along the imaginary axis.
106+
107+
*Note: branch cuts have provisional status* (see :ref:`branch-cuts`).
108+
66109
Parameters
67110
----------
68111
x: array
69-
input array whose elements each represent the area of a hyperbolic sector. Should have a real-valued floating-point data type.
112+
input array whose elements each represent the area of a hyperbolic sector. Should have a floating-point data type.
70113
71114
Returns
72115
-------
73116
out: array
74-
an array containing the inverse hyperbolic cosine of each element in ``x``. The returned array must have a real-valued floating-point data type determined by :ref:`type-promotion`.
117+
an array containing the inverse hyperbolic cosine of each element in ``x``. The returned array must have a floating-point data type determined by :ref:`type-promotion`.
75118
"""
76119

77120
def add(x1: array, x2: array, /) -> array:

0 commit comments

Comments
 (0)