\frac{e^{x}}{e^{x} - 1}\begin{array}{l}
\mathbf{if}\;e^{x} \le 0.0:\\
\;\;\;\;\frac{1}{1 - \frac{1}{e^{x}}}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{12}, x, \frac{1}{x}\right) + \frac{1}{2}\\
\end{array}double code(double x) {
return (exp(x) / (exp(x) - 1.0));
}
double code(double x) {
double VAR;
if ((exp(x) <= 0.0)) {
VAR = (1.0 / (1.0 - (1.0 / exp(x))));
} else {
VAR = (fma(0.08333333333333333, x, (1.0 / x)) + 0.5);
}
return VAR;
}




Bits error versus x
Results
| Original | 40.8 |
|---|---|
| Target | 40.4 |
| Herbie | 0.8 |
if (exp x) < 0.0Initial program 0
rmApplied clear-num0
Simplified0
if 0.0 < (exp x) Initial program 61.4
Taylor expanded around 0 1.2
Simplified1.2
Final simplification0.8
herbie shell --seed 2020103 +o rules:numerics
(FPCore (x)
:name "expq2 (section 3.11)"
:precision binary64
:herbie-target
(/ 1 (- 1 (exp (- x))))
(/ (exp x) (- (exp x) 1)))