mxnet.np.log1p

log1p(x, out=None, **kwargs)

Return the natural logarithm of one plus the input array, element-wise. Calculates log(1 + x).

Parameters
  • x (ndarray or scalar) – Input array.

  • out (ndarray or None) – A location into which the result is stored. If provided, it must have a shape that the inputs fill into. If not provided or None, a freshly-allocated array is returned. The dtype of the output and input must be the same.

Returns

y – Natural logarithm of 1 + x, element-wise. This is a scalar if x is a scalar.

Return type

ndarray or scalar

Notes

For real-valued input, log1p is accurate also for x so small that 1 + x == 1 in floating-point accuracy. Logarithm is a multivalued function: for each x there is an infinite number of z such that exp(z) = 1 + x. The convention is to return the z whose imaginary part lies in [-pi, pi]. For real-valued input data types, log1p always returns real output. For each value that cannot be expressed as a real number or infinity, it yields nan and sets the invalid floating point error flag. cannot support complex-valued input.

Examples

>>> np.log1p(1e-99)
1e-99
>>> a = np.array([3, 4, 5])
>>> np.log1p(a)
array([1.3862944, 1.609438 , 1.7917595])