\frac{e^{x} - 1}{x}\begin{array}{l}
\mathbf{if}\;x \le -2.285697559519662 \cdot 10^{-4}:\\
\;\;\;\;e^{x} \cdot \frac{1}{x} - \frac{1}{x}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\frac{1}{2} + x \cdot \frac{1}{6}\right) + 1\\
\end{array}double code(double x) {
return ((exp(x) - 1.0) / x);
}
double code(double x) {
double temp;
if ((x <= -0.0002285697559519662)) {
temp = ((exp(x) * (1.0 / x)) - (1.0 / x));
} else {
temp = ((x * (0.5 + (x * 0.16666666666666666))) + 1.0);
}
return temp;
}




Bits error versus x
Results
| Original | 39.8 |
|---|---|
| Target | 40.2 |
| Herbie | 0.4 |
if x < -0.0002285697559519662Initial program 0.1
rmApplied div-sub0.1
rmApplied div-inv0.1
if -0.0002285697559519662 < x Initial program 60.0
Taylor expanded around 0 0.5
rmApplied associate-+r+0.5
Simplified0.5
Final simplification0.4
herbie shell --seed 2020057
(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))