sqrt¶
- sqrt(x: array, /) array¶
Calculates the principal square root for each element
x_iof the input arrayx.Note
After rounding, each result must be indistinguishable from the infinitely precise result (as required by IEEE 754).
Note
For complex floating-point operands,
sqrt(conj(x))must equalconj(sqrt(x)).Note
By convention, the branch cut of the square root is the negative real axis \((-\infty, 0)\).
The square root is a continuous function from above the branch cut, taking into account the sign of the imaginary component.
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 \([0, +\infty)\) along the real axis and \((-\infty, +\infty)\) along the imaginary axis).
Note: branch cuts follow C99 and have provisional status (see Branch Cuts).
- Parameters:
x (array) – input array. Should have a floating-point data type.
- Returns:
out (array) – an array containing the square root of each element in
x. The returned array must have a floating-point data type determined by Type Promotion Rules.
Notes
Special cases
For real-valued floating-point operands,
If
x_iisNaN, the result isNaN.If
x_iis less than0, the result isNaN.If
x_iis+0, the result is+0.If
x_iis-0, the result is-0.If
x_iis+infinity, the result is+infinity.
For complex floating-point operands, let
a = real(x_i),b = imag(x_i), andIf
ais either+0or-0andbis+0, the result is+0 + 0j.If
ais any value (includingNaN) andbis+infinity, the result is+infinity + infinity j.If
ais a finite number andbisNaN, the result isNaN + NaN j.If
a-infinityandbis a positive (i.e., greater than0) finite number, the result isNaN + NaN j.If
ais+infinityandbis a positive (i.e., greater than0) finite number, the result is+0 + infinity j.If
ais-infinityandbisNaN, the result isNaN + infinity j(sign of the imaginary component is unspecified).If
ais+infinityandbisNaN, the result is+infinity + NaN j.If
aisNaNandbis any value, the result isNaN + NaN j.If
aisNaNandbisNaN, the result isNaN + NaN j.
Changed in version 2022.12: Added complex data type support.