\frac{e^{x}}{e^{x} - 1}\begin{array}{l}
\mathbf{if}\;x \le -0.0014783118370881984:\\
\;\;\;\;\frac{1}{\frac{\mathsf{fma}\left(-1, 1, e^{x + x}\right)}{{\left(e^{x}\right)}^{3} + {1}^{3}}} \cdot \frac{e^{x}}{\mathsf{fma}\left(1, 1 - e^{x}, e^{2 \cdot x}\right)}\\
\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 ((x <= -0.0014783118370881984)) {
VAR = ((1.0 / (fma(-1.0, 1.0, exp((x + x))) / (pow(exp(x), 3.0) + pow(1.0, 3.0)))) * (exp(x) / fma(1.0, (1.0 - exp(x)), exp((2.0 * x)))));
} else {
VAR = (fma(0.08333333333333333, x, (1.0 / x)) + 0.5);
}
return VAR;
}




Bits error versus x
Results
| Original | 41.1 |
|---|---|
| Target | 40.7 |
| Herbie | 0.6 |
if x < -0.0014783118370881984Initial program 0.0
rmApplied flip--0.0
Simplified0.0
rmApplied flip3-+0.0
Applied associate-/r/0.0
Applied *-un-lft-identity0.0
Applied times-frac0.0
Simplified0.0
if -0.0014783118370881984 < x Initial program 61.9
Taylor expanded around 0 0.9
Simplified0.9
Final simplification0.6
herbie shell --seed 2020106 +o rules:numerics
(FPCore (x)
:name "expq2 (section 3.11)"
:precision binary64
:herbie-target
(/ 1 (- 1 (exp (- x))))
(/ (exp x) (- (exp x) 1)))