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




Bits error versus x
Results
| Original | 39.8 |
|---|---|
| Target | 40.1 |
| Herbie | 0.3 |
if x < -0.00014016872383617292Initial program 0.1
rmApplied flip--0.1
Simplified0.0
rmApplied add-log-exp0.1
if -0.00014016872383617292 < x Initial program 59.9
Taylor expanded around 0 0.5
Simplified0.5
Final simplification0.3
herbie shell --seed 2020114 +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))