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




Bits error versus x
Results
| Original | 41.3 |
|---|---|
| Target | 40.9 |
| Herbie | 0.7 |
if (exp.f64 x) < 2.9364953566114182e-64Initial program 0
rmApplied add-sqr-sqrt_binary64_7720
Applied difference-of-sqr-1_binary64_7210
Applied *-un-lft-identity_binary64_7510
Applied times-frac_binary64_7570
Simplified0
Simplified0
if 2.9364953566114182e-64 < (exp.f64 x) Initial program 61.8
Taylor expanded around 0 1.1
Simplified1.1
Final simplification0.7
herbie shell --seed 2020289
(FPCore (x)
:name "expq2 (section 3.11)"
:precision binary64
:herbie-target
(/ 1.0 (- 1.0 (exp (- x))))
(/ (exp x) (- (exp x) 1.0)))