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




Bits error versus x
Results
| Original | 39.8 |
|---|---|
| Target | 40.2 |
| Herbie | 0.3 |
if x < -0.0189084102459027Initial program 0.0
rmApplied clear-num_binary64_14410.0
rmApplied *-un-lft-identity_binary64_14420.0
Applied associate-/r*_binary64_13860.0
if -0.0189084102459027 < x Initial program 60.0
rmApplied clear-num_binary64_144160.0
Taylor expanded around 0 0.4
Final simplification0.3
herbie shell --seed 2021079
(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))