\frac{e^{x}}{e^{x} - 1}\begin{array}{l}
\mathbf{if}\;e^{x} \le 0.99740808223063815:\\
\;\;\;\;\frac{e^{x}}{\left(\sqrt[3]{\frac{{\left(e^{2}\right)}^{x} - 1 \cdot 1}{e^{x} + 1}} \cdot \sqrt[3]{\frac{{\left(e^{2}\right)}^{x} - 1 \cdot 1}{e^{x} + 1}}\right) \cdot \sqrt[3]{\frac{{\left(e^{2}\right)}^{x} - 1 \cdot 1}{e^{x} + 1}}}\\
\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.9974080822306381)) {
VAR = (exp(x) / ((cbrt(((pow(exp(2.0), x) - (1.0 * 1.0)) / (exp(x) + 1.0))) * cbrt(((pow(exp(2.0), x) - (1.0 * 1.0)) / (exp(x) + 1.0)))) * cbrt(((pow(exp(2.0), 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.7 |
|---|---|
| Target | 41.2 |
| Herbie | 0.6 |
if (exp x) < 0.9974080822306381Initial program 0.0
rmApplied flip--0.0
rmApplied *-un-lft-identity0.0
Applied exp-prod0.0
Applied *-un-lft-identity0.0
Applied exp-prod0.0
Applied pow-prod-down0.0
Simplified0.0
rmApplied add-cube-cbrt0.0
if 0.9974080822306381 < (exp x) Initial program 62.0
Taylor expanded around 0 0.9
Final simplification0.6
herbie shell --seed 2020091
(FPCore (x)
:name "expq2 (section 3.11)"
:precision binary64
:herbie-target
(/ 1 (- 1 (exp (- x))))
(/ (exp x) (- (exp x) 1)))