\frac{e^{x}}{e^{x} - 1}\begin{array}{l}
\mathbf{if}\;e^{x} \leq 1.1857370595327356 \cdot 10^{-16}:\\
\;\;\;\;\frac{e^{x}}{\frac{{\left(e^{x}\right)}^{3} - 1}{1 + e^{x} \cdot \left(e^{x} + 1\right)}}\\
\mathbf{else}:\\
\;\;\;\;x \cdot 0.08333333333333333 + \left(0.5 + \frac{1}{x}\right)\\
\end{array}(FPCore (x) :precision binary64 (/ (exp x) (- (exp x) 1.0)))
(FPCore (x)
:precision binary64
(if (<= (exp x) 1.1857370595327356e-16)
(/
(exp x)
(/ (- (pow (exp x) 3.0) 1.0) (+ 1.0 (* (exp x) (+ (exp x) 1.0)))))
(+ (* x 0.08333333333333333) (+ 0.5 (/ 1.0 x)))))double code(double x) {
return exp(x) / (exp(x) - 1.0);
}
double code(double x) {
double tmp;
if (exp(x) <= 1.1857370595327356e-16) {
tmp = exp(x) / ((pow(exp(x), 3.0) - 1.0) / (1.0 + (exp(x) * (exp(x) + 1.0))));
} else {
tmp = (x * 0.08333333333333333) + (0.5 + (1.0 / x));
}
return tmp;
}




Bits error versus x
Results
| Original | 41.3 |
|---|---|
| Target | 40.9 |
| Herbie | 0.7 |
if (exp.f64 x) < 1.1857370595327356e-16Initial program 0
rmApplied flip3--_binary64_7550.0
Simplified0.0
Simplified0.0
if 1.1857370595327356e-16 < (exp.f64 x) Initial program 61.5
Taylor expanded around 0 1.1
Simplified1.1
Final simplification0.7
herbie shell --seed 2020303
(FPCore (x)
:name "expq2 (section 3.11)"
:precision binary64
:herbie-target
(/ 1.0 (- 1.0 (exp (- x))))
(/ (exp x) (- (exp x) 1.0)))