exprel#
- class brainunit.math.exprel(x, **kwargs)#
Relative error exponential,
(exp(x) - 1)/x.When
xis near zero,exp(x)is near 1, so the numerical calculation ofexp(x) - 1can suffer from catastrophic loss of precision.exprel(x)is implemented to avoid the loss of precision that occurs whenxis near zero.The threshold for switching between Taylor series and direct computation is adaptive based on the input dtype for optimal numerical stability.
- Parameters:
x (saiunit.Quantity |
Array|ndarray|bool|number|bool|int|float|complex) – ndarray. Input array.xmust contain real numbers.- Return type:
Array- Returns:
(exp(x) - 1)/x, computed element-wise.
Notes
Use
saiunit.math.set_exprel_order(n)to control the Taylor series order (default: 5). Higher values provide better accuracy near x=0 but require more computation.