bundles / numpy 2.4.4 / numpy / lib / scimath / power
_ArrayFunctionDispatcher
numpy.lib.scimath:power
source: /numpy/lib/_scimath_impl.py:439
Signature
def power(x, p)Summary
Return x to the power p, (x**p).
Extended Summary
If x contains negative values, the output is converted to the complex domain.
Parameters
x: array_likeThe input value(s).
p: array_like of intsThe power(s) to which
xis raised. Ifxcontains multiple values,phas to either be a scalar, or contain the same number of values asx. In the latter case, the result isx[0]**p[0], x[1]**p[1], ....
Returns
out: ndarray or scalarThe result of
x**p. Ifxandpare scalars, so is out, otherwise an array is returned.
Examples
import numpy as np np.set_printoptions(precision=4)✓
np.emath.power(2, 2)
✗np.int64(4)
np.emath.power([2, 4], 2)
✓array([ 4, 16])
np.emath.power([2, 4], -2)
✗array([0.25 , 0.0625])
np.emath.power([-2, 4], 2)
✓array([ 4.-0.j, 16.+0.j])
np.emath.power([2, 4], [2, 4])
✗array([ 4, 256])
See also
Aliases
numpy.emath.power