fn

expm1

Tensor
expm1(x: Tensor)
source

Element-wise ex1e^{x} - 1.

Computes the exponential-minus-one function. The current composite implementation evaluates the naive form exp(x) - 1; a dedicated engine primitive would additionally preserve relative accuracy for x1|x| \ll 1, but the algebraic result is identical.

Parameters

xTensor
Input tensor. Any floating-point dtype.

Returns

Tensor

Element-wise ex1e^{x} - 1.

Notes

Mathematical definition:

outi=exi1.\text{out}_i = e^{x_i} - 1.

The function is useful in probability and finance where xx is a small log-difference, since log(1 + y) = expm1⁻¹(y) and the pair avoids subtractive cancellation when chained.

Examples

>>> import lucid
>>> x = lucid.tensor([0.0, 1.0, 2.0])
>>> lucid.expm1(x)
Tensor([0.    , 1.71828, 6.38906])