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




Bits error versus x
Results
| Original | 41.6 |
|---|---|
| Target | 41.2 |
| Herbie | 0.0 |
if x < -0.0023625926649774231Initial program 0.0
rmApplied clear-num_binary640.0
Simplified0.0
if -0.0023625926649774231 < x < 0.0021021084497481325Initial program 62.5
Taylor expanded around 0 0.0
Simplified0.0
if 0.0021021084497481325 < x Initial program 33.0
rmApplied clear-num_binary6433.0
Simplified0.5
rmApplied add-log-exp_binary640.8
Applied add-log-exp_binary640.8
Applied diff-log_binary640.9
Simplified0.7
Final simplification0.0
herbie shell --seed 2020253
(FPCore (x)
:name "expq2 (section 3.11)"
:precision binary64
:herbie-target
(/ 1.0 (- 1.0 (exp (- x))))
(/ (exp x) (- (exp x) 1.0)))