numpy.emath.log#

emath.log(x)[source]#

Compute the natural logarithm ofx.

Return the “principal value” (for a description of this, seenumpy.log)of\(log_e(x)\). For realx > 0, this is a real number (log(0)returns-inf andlog(np.inf) returnsinf). Otherwise, thecomplex principle value is returned.

Parameters:
xarray_like

The value(s) whose log is (are) required.

Returns:
outndarray or scalar

The log of thex value(s). Ifx was a scalar, so isout,otherwise an array is returned.

See also

numpy.log

Notes

For a log() that returnsNAN when realx < 0, usenumpy.log(note, however, that otherwisenumpy.log and thislog are identical,i.e., both return-inf forx = 0,inf forx = inf, and,notably, the complex principle value ifx.imag!=0).

Examples

>>>importnumpyasnp>>>np.emath.log(np.exp(1))1.0

Negative arguments are handled “correctly” (recall thatexp(log(x))==x doesnot hold for realx<0):

>>>np.emath.log(-np.exp(1))==(1+np.pi*1j)True
On this page