exprel

Contents

exprel#

class brainunit.math.exprel(x, **kwargs)#

Relative error exponential, (exp(x) - 1)/x.

When x is near zero, exp(x) is near 1, so the numerical calculation of exp(x) - 1 can suffer from catastrophic loss of precision. exprel(x) is implemented to avoid the loss of precision that occurs when x is 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. x must 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.