\frac{e^{x} - 1}{x}\begin{array}{l}
\mathbf{if}\;x \le -7.3728617883948687 \cdot 10^{-5}:\\
\;\;\;\;\frac{\log \left(e^{e^{x} - 1}\right)}{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 VAR;
if ((x <= -7.372861788394869e-05)) {
VAR = (log(exp((exp(x) - 1.0))) / x);
} else {
VAR = ((x * (0.5 + (x * 0.16666666666666666))) + 1.0);
}
return VAR;
}




Bits error versus x
Results
| Original | 39.7 |
|---|---|
| Target | 40.1 |
| Herbie | 0.4 |
if x < -7.372861788394869e-05Initial program 0.1
rmApplied add-log-exp0.1
Applied add-log-exp0.1
Applied diff-log0.1
Simplified0.1
if -7.372861788394869e-05 < x Initial program 59.9
Taylor expanded around 0 0.6
rmApplied associate-+r+0.6
Simplified0.6
Final simplification0.4
herbie shell --seed 2020105
(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))