\frac{e^{x} - 1}{x}\begin{array}{l}
\mathbf{if}\;x \le -1.69715010585821388 \cdot 10^{-4}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(-1, 1, e^{x + x}\right)}{e^{x} + 1}}{x}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{expm1}\left(\mathsf{fma}\left(\frac{5}{96}, {x}^{2}, \mathsf{fma}\left(\frac{1}{4}, x, \log 2\right)\right)\right)\\
\end{array}double code(double x) {
return ((exp(x) - 1.0) / x);
}
double code(double x) {
double temp;
if ((x <= -0.0001697150105858214)) {
temp = ((fma(-1.0, 1.0, exp((x + x))) / (exp(x) + 1.0)) / x);
} else {
temp = expm1(fma(0.052083333333333336, pow(x, 2.0), fma(0.25, x, log(2.0))));
}
return temp;
}




Bits error versus x
Results
| Original | 39.8 |
|---|---|
| Target | 40.2 |
| Herbie | 0.4 |
if x < -0.0001697150105858214Initial program 0.1
rmApplied flip--0.1
Simplified0.0
if -0.0001697150105858214 < x Initial program 60.0
Taylor expanded around 0 0.5
Simplified0.5
rmApplied expm1-log1p-u0.5
Taylor expanded around 0 0.5
Simplified0.5
Final simplification0.4
herbie shell --seed 2020057 +o rules:numerics
(FPCore (x)
:name "Kahan's exp quotient"
:precision binary64
:herbie-target
(if (and (< x 1) (> x -1)) (/ (- (exp x) 1) (log (exp x))) (/ (- (exp x) 1) x))
(/ (- (exp x) 1) x))