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





Bits error versus x
Results
| Original | 41.0 |
|---|---|
| Target | 40.4 |
| Herbie | 0.4 |
| Alternative 1 | |
|---|---|
| Accuracy | 1.2 |
| Cost | 960 |
if (exp.f64 x) < 1.00000187708529631Initial program 41.1
Taylor expanded around 0 11.2
Simplified0.3
rmApplied frac-2neg_binary64_7710.3
Simplified0.3
rmApplied associate-/r*_binary64_7040.3
if 1.00000187708529631 < (exp.f64 x) Initial program 33.3
rmApplied clear-num_binary64_75933.3
Simplified2.4
Final simplification0.4
herbie shell --seed 2020322
(FPCore (x)
:name "expq2 (section 3.11)"
:precision binary64
:herbie-target
(/ 1.0 (- 1.0 (exp (- x))))
(/ (exp x) (- (exp x) 1.0)))