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




Bits error versus x
Results
| Original | 40.1 |
|---|---|
| Target | 40.5 |
| Herbie | 0.2 |
if x < -8.1784553249516665e-4Initial program 0.0
rmApplied add-cbrt-cube_binary640.0
Simplified0.0
rmApplied flip--_binary640.0
Simplified0.0
rmApplied add-sqr-sqrt_binary640.0
Applied *-un-lft-identity_binary640.0
Applied times-frac_binary640.0
Applied unpow-prod-down_binary640.0
Applied cbrt-prod_binary640.0
Simplified0.0
Simplified0.0
if -8.1784553249516665e-4 < x Initial program 60.0
Taylor expanded around 0 0.3
Simplified0.3
Final simplification0.2
herbie shell --seed 2021118
(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))