Compute the natural logarithm of x.
Return the “principal value” (for a description of this, see
numpy.log) of \(log_e(x)\). For real x > 0, this is a real number (
inf). Otherwise, the complex principle value is returned.
The value(s) whose log is (are) required.
- outndarray or scalar
The log of the x value(s). If x was a scalar, so is out, otherwise an array is returned.
For a log() that returns
NANwhen real x < 0, use
numpy.log(note, however, that otherwise
logare identical, i.e., both return
-inffor x = 0,
inffor x = inf, and, notably, the complex principle value if
x.imag != 0).
>>> np.emath.log(np.exp(1)) 1.0
Negative arguments are handled “correctly” (recall that
exp(log(x)) == xdoes not hold for real
x < 0):
>>> np.emath.log(-np.exp(1)) == (1 + np.pi * 1j) True