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




Bits error versus x
Results
| Original | 41.4 |
|---|---|
| Target | 41.1 |
| Herbie | 0.3 |
if x < 1.5152468779096654e-4Initial program 41.6
Taylor expanded around 0 10.9
Simplified0.3
if 1.5152468779096654e-4 < x Initial program 29.1
rmApplied clear-num_binary64_76629.1
Simplified1.2
rmApplied add-sqr-sqrt_binary64_7891.2
Applied add-sqr-sqrt_binary64_7891.2
Applied times-frac_binary64_7731.3
Simplified1.3
Simplified1.3
Final simplification0.3
herbie shell --seed 2020280
(FPCore (x)
:name "expq2 (section 3.11)"
:precision binary64
:herbie-target
(/ 1.0 (- 1.0 (exp (- x))))
(/ (exp x) (- (exp x) 1.0)))