numpy.emath.power#

emath.power(x,p)[source]#

Return x to the power p, (x**p).

Ifx contains negative values, the output is converted to thecomplex domain.

Parameters:
xarray_like

The input value(s).

parray_like of ints

The power(s) to whichx is raised. Ifx contains multiple values,p has to either be a scalar, or contain the same number of valuesasx. In the latter case, the result isx[0]**p[0],x[1]**p[1],....

Returns:
outndarray or scalar

The result ofx**p. Ifx andp are scalars, so isout,otherwise an array is returned.

See also

numpy.power

Examples

>>>importnumpyasnp>>>np.set_printoptions(precision=4)
>>>np.emath.power(2,2)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])
On this page