Skip to content

Commit 1d1833f

Browse files
authored
Add complex support to asin (#521)
1 parent c1fbd4d commit 1d1833f

File tree

1 file changed

+30
-5
lines changed

1 file changed

+30
-5
lines changed

spec/API_specification/array_api/elementwise_functions.py

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,28 +117,53 @@ def add(x1: array, x2: array, /) -> array:
117117
"""
118118

119119
def asin(x: array, /) -> array:
120-
"""
121-
Calculates an implementation-dependent approximation of the principal value of the inverse sine, having domain ``[-1, +1]`` and codomain ``[-π/2, +π/2]`` for each element ``x_i`` of the input array ``x``. Each element-wise result is expressed in radians.
120+
r"""
121+
Calculates an implementation-dependent approximation of the principal value of the inverse sine for each element ``x_i`` of the input array ``x``.
122+
123+
Each element-wise result is expressed in radians.
122124
123125
**Special cases**
124126
125-
For floating-point operands,
127+
For real-valued floating-point operands,
126128
127129
- If ``x_i`` is ``NaN``, the result is ``NaN``.
128130
- If ``x_i`` is greater than ``1``, the result is ``NaN``.
129131
- If ``x_i`` is less than ``-1``, the result is ``NaN``.
130132
- If ``x_i`` is ``+0``, the result is ``+0``.
131133
- If ``x_i`` is ``-0``, the result is ``-0``.
132134
135+
For complex floating-point operands, special cases must be handled as if the operation is implemented as ``-1j * asinh(x*1j)``.
136+
137+
.. note::
138+
The principal value of the arc sine of a complex number :math:`z` is
139+
140+
.. math::
141+
\operatorname{asin}(z) = -j\ \ln(zj + \sqrt{1-z^2})
142+
143+
For any :math:`z`,
144+
145+
.. math::
146+
\operatorname{asin}(z) = \operatorname{acos}(-z) - \frac{\pi}{2}
147+
148+
.. note::
149+
For complex floating-point operands, ``asin(conj(x))`` must equal ``conj(asin(x))``.
150+
151+
.. note::
152+
The inverse sine (or arc 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, -1)` and :math:`(1, \infty)` of the real axis.
153+
154+
Accordingly, for complex arguments, the function returns the inverse sine in the range of a strip unbounded along the imaginary axis and in the interval :math:`[-\pi/2, +\pi/2]` along the real axis.
155+
156+
*Note: branch cuts have provisional status* (see :ref:`branch-cuts`).
157+
133158
Parameters
134159
----------
135160
x: array
136-
input array. Should have a real-valued floating-point data type.
161+
input array. Should have a floating-point data type.
137162
138163
Returns
139164
-------
140165
out: array
141-
an array containing the inverse sine of each element in ``x``. The returned array must have a real-valued floating-point data type determined by :ref:`type-promotion`.
166+
an array containing the inverse sine of each element in ``x``. The returned array must have a floating-point data type determined by :ref:`type-promotion`.
142167
"""
143168

144169
def asinh(x: array, /) -> array:

0 commit comments

Comments
 (0)