Commits


Felipe Oliveira Carvalho authored and GitHub committed 5e476b3d365
GH-44903: [C++] Add the Expm1(exponent) scalar arithmetic function (#44904) `Expm1(exponent)` is a more accurate way of computing `Exp(exponent) - 1.0` for small values of exponent. ### Rationale for this change `expm1(x)` is specifically designed to compute `exp(x)−1` more accurately, particularly for small x. It uses numerical techniques and approximations that minimize the loss of precision. When x is very small (close to 0), `exp(x)` is approximately `1+x`. Subtracting 1 from `exp(x)` (i.e., `(exp(x)−1)` can result in significant cancellation of significant digits due to floating-point arithmetic, leading to a loss of precision). For example: When `x = 10^−8`, `exp(x)` is close to `1 + 10^−8`, so subtracting 1 leaves only the small `10^−8`, which may lose accuracy due to floating-point limitations. ### Are these changes tested? Yes. ### Are there any user-facing changes? Yes and documentation was updated to list the new function. * GitHub Issue: #44903 Authored-by: Felipe Oliveira Carvalho <felipekde@gmail.com> Signed-off-by: Felipe Oliveira Carvalho <felipekde@gmail.com>