\frac{e^{x} - 1}{x}\begin{array}{l}
\mathbf{if}\;x \le -1.9141971874233585 \cdot 10^{-4}:\\
\;\;\;\;\frac{\log \left(e^{e^{x} - 1}\right)}{x}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{6}, {x}^{2}, \mathsf{fma}\left(\frac{1}{2}, x, 1\right)\right)\\
\end{array}double code(double x) {
return ((exp(x) - 1.0) / x);
}
double code(double x) {
double temp;
if ((x <= -0.00019141971874233585)) {
temp = (log(exp((exp(x) - 1.0))) / x);
} else {
temp = fma(0.16666666666666666, pow(x, 2.0), fma(0.5, x, 1.0));
}
return temp;
}




Bits error versus x
Results
| Original | 39.8 |
|---|---|
| Target | 40.2 |
| Herbie | 0.4 |
if x < -0.00019141971874233585Initial program 0.0
rmApplied add-log-exp0.0
Applied add-log-exp0.1
Applied diff-log0.1
Simplified0.1
if -0.00019141971874233585 < x Initial program 60.1
Taylor expanded around 0 0.5
Simplified0.5
Final simplification0.4
herbie shell --seed 2020060 +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))