\frac{e^{x}}{e^{x} - 1}\begin{array}{l}
\mathbf{if}\;e^{x} \le 0.992455376038477222:\\
\;\;\;\;\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 VAR;
if ((exp(x) <= 0.9924553760384772)) {
VAR = (1.0 / (1.0 - (1.0 / exp(x))));
} else {
VAR = (0.5 + ((0.08333333333333333 * x) + (1.0 / x)));
}
return VAR;
}




Bits error versus x
Results
| Original | 41.1 |
|---|---|
| Target | 40.7 |
| Herbie | 0.7 |
if (exp x) < 0.9924553760384772Initial program 0.0
rmApplied clear-num0.0
Simplified0.0
if 0.9924553760384772 < (exp x) Initial program 61.5
Taylor expanded around 0 1.0
Final simplification0.7
herbie shell --seed 2020105
(FPCore (x)
:name "expq2 (section 3.11)"
:precision binary64
:herbie-target
(/ 1 (- 1 (exp (- x))))
(/ (exp x) (- (exp x) 1)))