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




Bits error versus x
Results
| Original | 41.9 |
|---|---|
| Target | 41.5 |
| Herbie | 0.8 |
if x < -4.2296754081445479e-6Initial program 0.1
rmApplied flip--_binary640.1
Applied associate-/r/_binary640.1
Simplified0.1
if -4.2296754081445479e-6 < x Initial program 62.2
Taylor expanded around 0 1.1
rmApplied div-inv_binary641.1
Final simplification0.8
herbie shell --seed 2020277
(FPCore (x)
:name "expq2 (section 3.11)"
:precision binary64
:herbie-target
(/ 1.0 (- 1.0 (exp (- x))))
(/ (exp x) (- (exp x) 1.0)))