bundles / numpy 2.4.3 / numpy / lib / scimath / log
_ArrayFunctionDispatcher
numpy.lib.scimath:log
source: /numpy/lib/_scimath_impl.py :241
Signature
def log ( x ) Summary
Compute the natural logarithm of x.
Extended Summary
Return the "principal value" (for a description of this, see numpy.log) of . For real x > 0, this is a real number (log(0) returns -inf and log(np.inf) returns inf). Otherwise, the complex principle value is returned.
Parameters
x: array_likeThe value(s) whose log is (are) required.
Returns
out: ndarray or scalarThe log of the
xvalue(s). Ifxwas a scalar, so is out, otherwise an array is returned.
Notes
For a log() that returns NAN when real x < 0, use numpy.log (note, however, that otherwise numpy.log and this log are identical, i.e., both return -inf for x = 0, inf for x = inf, and, notably, the complex principle value if x.imag != 0).
Examples
import numpy as np
✓np.emath.log(np.exp(1))
✗np.emath.log(-np.exp(1)) == (1 + np.pi * 1j)
✗See also
Aliases
-
numpy.emath.log