\frac{e^{x}}{e^{x} - 1}\begin{array}{l}
\mathbf{if}\;e^{x} \le 0.0:\\
\;\;\;\;\sqrt[3]{{\left(\frac{e^{x}}{e^{x} - 1}\right)}^{3}}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{x}}{\frac{1}{2} \cdot {x}^{2} + \left(\frac{1}{6} \cdot {x}^{3} + x\right)}\\
\end{array}double code(double x) {
return (exp(x) / (exp(x) - 1.0));
}
double code(double x) {
double temp;
if ((exp(x) <= 0.0)) {
temp = cbrt(pow((exp(x) / (exp(x) - 1.0)), 3.0));
} else {
temp = (exp(x) / ((0.5 * pow(x, 2.0)) + ((0.16666666666666666 * pow(x, 3.0)) + x)));
}
return temp;
}




Bits error versus x
Results
| Original | 41.9 |
|---|---|
| Target | 41.5 |
| Herbie | 1.0 |
if (exp x) < 0.0Initial program 0
rmApplied add-cbrt-cube0
Applied add-cbrt-cube0
Applied cbrt-undiv0
Simplified0
if 0.0 < (exp x) Initial program 61.4
Taylor expanded around 0 1.4
Final simplification1.0
herbie shell --seed 2020066
(FPCore (x)
:name "expq2 (section 3.11)"
:precision binary64
:herbie-target
(/ 1 (- 1 (exp (- x))))
(/ (exp x) (- (exp x) 1)))