A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://numpy.org/devdocs/reference/generated/numpy.emath.sqrt.html below:

numpy.emath.sqrt — NumPy v2.4.dev0 Manual

numpy.emath.sqrt#
emath.sqrt(x)[source]#

Compute the square root of x.

For negative input elements, a complex value is returned (unlike numpy.sqrt which returns NaN).

Parameters:
xarray_like

The input value(s).

Returns:
outndarray or scalar

The square root of x. If x was a scalar, so is out, otherwise an array is returned.

Examples

For real, non-negative inputs this works just like numpy.sqrt:

>>> np.emath.sqrt(1)
1.0
>>> np.emath.sqrt([1, 4])
array([1.,  2.])

But it automatically handles negative inputs:

>>> np.emath.sqrt(-1)
1j
>>> np.emath.sqrt([-1,4])
array([0.+1.j, 2.+0.j])

Different results are expected because: floating point 0.0 and -0.0 are distinct.

For more control, explicitly use complex() as follows:

>>> np.emath.sqrt(complex(-4.0, 0.0))
2j
>>> np.emath.sqrt(complex(-4.0, -0.0))
-2j

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4