\frac{e^{x}}{e^{x} - 1}\begin{array}{l}
\mathbf{if}\;e^{x} \leq 0.6026705682579042:\\
\;\;\;\;\sqrt{e^{x}} \cdot \frac{\sqrt{e^{x}}}{e^{x} - 1}\\
\mathbf{else}:\\
\;\;\;\;0.5 + \left(x \cdot 0.08333333333333333 + \frac{1}{x}\right)\\
\end{array}double code(double x) {
return (((double) exp(x)) / ((double) (((double) exp(x)) - 1.0)));
}
double code(double x) {
double VAR;
if ((((double) exp(x)) <= 0.6026705682579042)) {
VAR = ((double) (((double) sqrt(((double) exp(x)))) * (((double) sqrt(((double) exp(x)))) / ((double) (((double) exp(x)) - 1.0)))));
} else {
VAR = ((double) (0.5 + ((double) (((double) (x * 0.08333333333333333)) + (1.0 / x)))));
}
return VAR;
}




Bits error versus x
Results
| Original | 41.4 |
|---|---|
| Target | 41.1 |
| Herbie | 0.6 |
if (exp x) < 0.602670568257904216Initial program Error: 0.0 bits
rmApplied *-un-lft-identityError: 0.0 bits
Applied add-sqr-sqrtError: 0.0 bits
Applied times-fracError: 0.0 bits
SimplifiedError: 0.0 bits
if 0.602670568257904216 < (exp x) Initial program Error: 61.6 bits
Taylor expanded around 0 Error: 0.9 bits
SimplifiedError: 0.9 bits
Final simplificationError: 0.6 bits
herbie shell --seed 2020200
(FPCore (x)
:name "expq2 (section 3.11)"
:precision binary64
:herbie-target
(/ 1.0 (- 1.0 (exp (- x))))
(/ (exp x) (- (exp x) 1.0)))