\frac{e^{x}}{e^{x} - 1}\begin{array}{l}
\mathbf{if}\;e^{x} \leq 0.787664626492611:\\
\;\;\;\;\frac{e^{x}}{\frac{{\left(e^{x}\right)}^{2} + -1}{e^{x} + 1}}\\
\mathbf{else}:\\
\;\;\;\;0.5 + \left(x \cdot 0.08333333333333333 + \frac{1}{x}\right)\\
\end{array}(FPCore (x) :precision binary64 (/ (exp x) (- (exp x) 1.0)))
(FPCore (x) :precision binary64 (if (<= (exp x) 0.787664626492611) (/ (exp x) (/ (+ (pow (exp x) 2.0) -1.0) (+ (exp x) 1.0))) (+ 0.5 (+ (* x 0.08333333333333333) (/ 1.0 x)))))
double code(double x) {
return (((double) exp(x)) / ((double) (((double) exp(x)) - 1.0)));
}
double code(double x) {
double tmp;
if ((((double) exp(x)) <= 0.787664626492611)) {
tmp = (((double) exp(x)) / (((double) (((double) pow(((double) exp(x)), 2.0)) + -1.0)) / ((double) (((double) exp(x)) + 1.0))));
} else {
tmp = ((double) (0.5 + ((double) (((double) (x * 0.08333333333333333)) + (1.0 / x)))));
}
return tmp;
}




Bits error versus x
Results
| Original | 41.0 |
|---|---|
| Target | 40.7 |
| Herbie | 0.5 |
if (exp.f64 x) < 0.78766462649261104Initial program 0.0
rmApplied flip--_binary640.0
Simplified0.0
if 0.78766462649261104 < (exp.f64 x) Initial program 61.7
Taylor expanded around 0 0.8
Simplified0.8
Final simplification0.5
herbie shell --seed 2020219
(FPCore (x)
:name "expq2 (section 3.11)"
:precision binary64
:herbie-target
(/ 1.0 (- 1.0 (exp (- x))))
(/ (exp x) (- (exp x) 1.0)))