\frac{e^{x}}{e^{x} - 1}\begin{array}{l}
\mathbf{if}\;e^{x} \le 0.0 \lor \neg \left(e^{x} \le 1.000000720604215\right):\\
\;\;\;\;\frac{1}{1 - \frac{1}{e^{x}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2} + \left(\frac{1}{12} \cdot x + \frac{1}{x}\right)\\
\end{array}double code(double x) {
return (exp(x) / (exp(x) - 1.0));
}
double code(double x) {
double temp;
if (((exp(x) <= 0.0) || !(exp(x) <= 1.000000720604215))) {
temp = (1.0 / (1.0 - (1.0 / exp(x))));
} else {
temp = (0.5 + ((0.08333333333333333 * x) + (1.0 / x)));
}
return temp;
}




Bits error versus x
Results
| Original | 41.1 |
|---|---|
| Target | 40.8 |
| Herbie | 0.3 |
if (exp x) < 0.0 or 1.000000720604215 < (exp x) Initial program 1.3
rmApplied clear-num1.3
Simplified0.2
if 0.0 < (exp x) < 1.000000720604215Initial program 61.9
Taylor expanded around 0 0.4
Final simplification0.3
herbie shell --seed 2020053
(FPCore (x)
:name "expq2 (section 3.11)"
:precision binary64
:herbie-target
(/ 1 (- 1 (exp (- x))))
(/ (exp x) (- (exp x) 1)))