numpy.expm1#
- numpy.expm1(x,/,out=None,*,where=True,casting='same_kind',order='K',dtype=None,subok=True[,signature])=<ufunc'expm1'>#
Calculate
exp(x)-1for all elements in the array.- Parameters:
- xarray_like
Input values.
- outndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must havea shape that the inputs broadcast to. If not provided or None,a freshly-allocated array is returned. A tuple (possible only as akeyword argument) must have length equal to the number of outputs.
- wherearray_like, optional
This condition is broadcast over the input. At locations where thecondition is True, theout array will be set to the ufunc result.Elsewhere, theout array will retain its original value.Note that if an uninitializedout array is created via the default
out=None, locations within it where the condition is False willremain uninitialized.- **kwargs
For other keyword-only arguments, see theufunc docs.
- Returns:
- outndarray or scalar
Element-wise exponential minus one:
out=exp(x)-1.This is a scalar ifx is a scalar.
See also
log1plog(1+x), the inverse of expm1.
Notes
This function provides greater precision than
exp(x)-1for small values ofx.Examples
The true value of
exp(1e-10)-1is1.00000000005e-10toabout 32 significant digits. This example shows the superiority ofexpm1 in this case.>>>importnumpyasnp>>>np.expm1(1e-10)1.00000000005e-10>>>np.exp(1e-10)-11.000000082740371e-10