\frac{e^{x}}{e^{x} - 1}\begin{array}{l}
\mathbf{if}\;e^{x} \le 0.94930661802810024:\\
\;\;\;\;\frac{e^{x}}{\sqrt[3]{{\left(e^{x \cdot 3} - {1}^{3}\right)}^{3}}} \cdot \left(e^{x} \cdot e^{x} + \left(1 \cdot 1 + e^{x} \cdot 1\right)\right)\\
\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.9493066180281002)) {
VAR = ((exp(x) / cbrt(pow((exp((x * 3.0)) - pow(1.0, 3.0)), 3.0))) * ((exp(x) * exp(x)) + ((1.0 * 1.0) + (exp(x) * 1.0))));
} 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.6 |
if (exp x) < 0.9493066180281002Initial program 0.0
rmApplied flip3--0.0
Applied associate-/r/0.0
rmApplied pow-exp0.0
rmApplied add-cbrt-cube0.0
Simplified0.0
if 0.9493066180281002 < (exp x) Initial program 61.7
Taylor expanded around 0 0.9
Final simplification0.6
herbie shell --seed 2020106
(FPCore (x)
:name "expq2 (section 3.11)"
:precision binary64
:herbie-target
(/ 1 (- 1 (exp (- x))))
(/ (exp x) (- (exp x) 1)))