scipy.special.log1p#
- scipy.special.log1p(x, out=None) = <ufunc 'log1p'>#
Calculates log(1 + x) for use when x is near zero.
- Parameters
- xarray_like
Real or complex valued input.
- outndarray, optional
Optional output array for the function results.
- Returns
- scalar or ndarray
Values of
log(1 + x)
.
Examples
>>> import scipy.special as sc
It is more accurate than using
log(1 + x)
directly forx
near 0. Note that in the below example1 + 1e-17 == 1
to double precision.>>> sc.log1p(1e-17) 1e-17 >>> np.log(1 + 1e-17) 0.0