You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Calculates the square root, having domain ``[0, +infinity]`` and codomain ``[0, +infinity]``, for each element ``x_i`` of the input array ``x``. After rounding, each result must be indistinguishable from the infinitely precise result (as required by IEEE 754).
1485
+
r"""
1486
+
Calculates the principal square root for each element ``x_i`` of the input array ``x``.
1487
+
1488
+
.. note::
1489
+
After rounding, each result must be indistinguishable from the infinitely precise result (as required by IEEE 754).
1487
1490
1488
1491
**Special cases**
1489
1492
1490
-
For floating-point operands,
1493
+
For real-valued floating-point operands,
1491
1494
1492
1495
- If ``x_i`` is ``NaN``, the result is ``NaN``.
1493
1496
- If ``x_i`` is less than ``0``, the result is ``NaN``.
1494
1497
- If ``x_i`` is ``+0``, the result is ``+0``.
1495
1498
- If ``x_i`` is ``-0``, the result is ``-0``.
1496
1499
- If ``x_i`` is ``+infinity``, the result is ``+infinity``.
1497
1500
1501
+
For complex floating-point operands, let ``a = real(x_i)``, ``b = imag(x_i)``, and
1502
+
1503
+
- If ``a`` is either ``+0`` or ``-0`` and ``b`` is ``+0``, the result is ``+0 + 0j``.
1504
+
- If ``a`` is any value (including ``NaN``) and ``b`` is ``+infinity``, the result is ``+infinity + infinity j``.
1505
+
- If ``a`` is a finite number and ``b`` is ``NaN``, the result is ``NaN + NaN j``.
1506
+
- If ``a`` ``-infinity`` and ``b`` is a positive (i.e., greater than ``0``) finite number, the result is ``NaN + NaN j``.
1507
+
- If ``a`` is ``+infinity`` and ``b`` is a positive (i.e., greater than ``0``) finite number, the result is ``+0 + infinity j``.
1508
+
- If ``a`` is ``-infinity`` and ``b`` is ``NaN``, the result is ``NaN + infinity j`` (sign of the imaginary component is unspecified).
1509
+
- If ``a`` is ``+infinity`` and ``b`` is ``NaN``, the result is ``+infinity + NaN j``.
1510
+
- If ``a`` is ``NaN`` and ``b`` is any value, the result is ``NaN + NaN j``.
1511
+
- If ``a`` is ``NaN`` and ``b`` is ``NaN``, the result is ``NaN + NaN j``.
1512
+
1513
+
.. note::
1514
+
For complex floating-point operands, ``sqrt(conj(x))`` must equal ``conj(sqrt(x))``.
1515
+
1516
+
.. note::
1517
+
By convention, the branch cut of the square root is the negative real axis :math:`(-\infty, 0)`.
1518
+
1519
+
The square root is a continuous function from above the branch cut, taking into account the sign of the imaginary component.
1520
+
1521
+
Accordingly, for complex arguments, the function returns the square root in the range of the right half-plane, including the imaginary axis (i.e., the plane defined by :math:`[0, +\infty)` along the real axis and :math:`(-\infty, +\infty)` along the imaginary axis).
1522
+
1523
+
*Note: branch cuts have provisional status* (see :ref:`branch-cuts`).
1524
+
1498
1525
Parameters
1499
1526
----------
1500
1527
x: array
1501
-
input array. Should have a real-valued floating-point data type.
1528
+
input array. Should have a floating-point data type.
1502
1529
1503
1530
Returns
1504
1531
-------
1505
1532
out: array
1506
-
an array containing the square root of each element in ``x``. The returned array must have a real-valued floating-point data type determined by :ref:`type-promotion`.
1533
+
an array containing the square root of each element in ``x``. The returned array must have a floating-point data type determined by :ref:`type-promotion`.
In the mathematical field of complex analysis, a **branch cut** is a curve in the complex plane across which an analytic multi-valued function is discontinuous. Branch cuts are often taken as lines or line segments, and the choice of any particular branch cut is a matter of convention.
7
+
8
+
For example, consider the function :math:`z^2` which maps a complex number :math:`z` to a well-defined number :math:`z^2`. The function's inverse function :math:`\sqrt{z}` does not, however, map to a single value. For example, for :math:`z = 1`, :math:`\sqrt{1} = \pm1`. While one can choose a unique principal value for this and similar functions (e.g., in this case, the principal square root is :math:`+1`), choices cannot be made continuous over the whole complex plane, as lines of discontinuity must occur. To handle discontinuities, one commonly adopts branch cuts, which are not, in general, unique. Instead, one chooses a branch cut as a matter of convention in order to give simple analytic properties.
9
+
10
+
Branch cuts do not arise for single-valued trigonometric, hyperbolic, integer power, or exponential functions; however, branch cuts do arise for their multi-valued inverses.
11
+
12
+
In contrast to real-valued floating-point numbers which have well-defined behavior as specified in IEEE 754, complex-valued floating-point numbers have no equivalent specification. Accordingly, this specification chooses to follow C99 conventions for special cases and branch cuts for those functions supporting complex numbers. For those functions which do not have C99 equivalents (e.g., linear algebra APIs), the specification relies on dominant conventions among existing array libraries.
13
+
14
+
.. warning::
15
+
All branch cuts documented in this specification are considered **provisional**. While conforming implementations of the array API standard should adopt the branch cuts described in this standard, consumers of array API standard implementations should **not** assume that branch cuts are consistent between implementations.
16
+
17
+
Provided no issues arise due to the choice of branch cut, the provisional status is likely to be removed in a future revision of this standard.
Copy file name to clipboardExpand all lines: spec/purpose_and_scope.md
+3
Original file line number
Diff line number
Diff line change
@@ -434,6 +434,9 @@ a (usually fixed-size) multidimensional container of items of the same type and
434
434
**axis**:
435
435
an array dimension.
436
436
437
+
**branch cut**:
438
+
a curve in the complex plane across which a given complex function fails to be continuous.
439
+
437
440
**broadcast**:
438
441
automatic (implicit) expansion of array dimensions to be of equal sizes without copying array data for the purpose of making arrays with different shapes have compatible shapes for element-wise operations.
0 commit comments