\frac{e^{x} - 1}{x}\begin{array}{l}
\mathbf{if}\;x \leq -6.4930921653586126 \cdot 10^{-06}:\\
\;\;\;\;\frac{\left(1 + \sqrt{e^{x}}\right) \cdot \left(\sqrt{e^{x}} - 1\right)}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{x + \frac{x \cdot x}{2}}{x}\\
\end{array}(FPCore (x) :precision binary64 (/ (- (exp x) 1.0) x))
(FPCore (x) :precision binary64 (if (<= x -6.4930921653586126e-06) (/ (* (+ 1.0 (sqrt (exp x))) (- (sqrt (exp x)) 1.0)) x) (/ (+ x (/ (* x x) 2.0)) x)))
double code(double x) {
return (exp(x) - 1.0) / x;
}
double code(double x) {
double tmp;
if (x <= -6.4930921653586126e-06) {
tmp = ((1.0 + sqrt(exp(x))) * (sqrt(exp(x)) - 1.0)) / x;
} else {
tmp = (x + ((x * x) / 2.0)) / x;
}
return tmp;
}




Bits error versus x
Results
| Original | 39.7 |
|---|---|
| Target | 40.2 |
| Herbie | 0.4 |
if x < -6.4930921653586126e-6Initial program 0.1
rmApplied add-sqr-sqrt_binary640.1
Applied difference-of-sqr-1_binary640.1
Simplified0.1
if -6.4930921653586126e-6 < x Initial program 60.2
Taylor expanded around 0 0.6
Final simplification0.4
herbie shell --seed 2020277
(FPCore (x)
:name "Kahan's exp quotient"
:precision binary64
:herbie-target
(if (and (< x 1.0) (> x -1.0)) (/ (- (exp x) 1.0) (log (exp x))) (/ (- (exp x) 1.0) x))
(/ (- (exp x) 1.0) x))