numpy.expm1

numpy.expm1(x[, out])

Return the exponential of the elements in the array minus one.

Parameters:

x : array_like

Input values.

Returns:

out : ndarray

Element-wise exponential minus one: out=exp(x)-1.

See also

log1p
log(1+x), the inverse of expm1.

Notes

This function provides greater precision than using exp(x)-1 for small values of x.

Examples

Since the series expansion of e**x = 1 + x + x**2/2! + x**3/3! + ..., for very small x we expect that e**x -1 ~ x + x**2/2:

>>> np.expm1(1e-10)
1.00000000005e-10
>>> np.exp(1e-10) - 1
1.000000082740371e-10

Previous topic

numpy.exp

Next topic

numpy.log

This Page

Quick search