\frac{e^{x}}{e^{x} - 1}\begin{array}{l}
\mathbf{if}\;e^{x} \leq 1.0000173072590348:\\
\;\;\;\;\frac{e^{x}}{x + x \cdot \left(x \cdot \left(0.5 + x \cdot 0.16666666666666666\right)\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.0000173072590348) (/ (exp x) (+ x (* x (* x (+ 0.5 (* x 0.16666666666666666)))))) (/ 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.0000173072590348) {
tmp = exp(x) / (x + (x * (x * (0.5 + (x * 0.16666666666666666)))));
} else {
tmp = 1.0 / (1.0 - exp(-x));
}
return tmp;
}




Bits error versus x
Results
| Original | 41.2 |
|---|---|
| Target | 40.8 |
| Herbie | 0.3 |
if (exp.f64 x) < 1.0000173072590348Initial program 41.4
Taylor expanded around 0 10.8
Simplified0.3
if 1.0000173072590348 < (exp.f64 x) Initial program 27.3
rmApplied clear-num_binary64_110027.4
Simplified1.9
Final simplification0.3
herbie shell --seed 2020354
(FPCore (x)
:name "expq2 (section 3.11)"
:precision binary64
:herbie-target
(/ 1.0 (- 1.0 (exp (- x))))
(/ (exp x) (- (exp x) 1.0)))