\frac{e^{x}}{e^{x} - 1}\begin{array}{l}
\mathbf{if}\;e^{x} \le 0.0184360243772397382:\\
\;\;\;\;\frac{e^{x}}{e^{x} - 1}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-x, \frac{1}{12}, \mathsf{fma}\left({x}^{3}, \frac{7}{720}, \frac{\frac{1}{2}}{x}\right)\right) \cdot \left(e^{x} + 1\right)\\
\end{array}double code(double x) {
return (exp(x) / (exp(x) - 1.0));
}
double code(double x) {
double temp;
if ((exp(x) <= 0.018436024377239738)) {
temp = (exp(x) / (exp(x) - 1.0));
} else {
temp = (fma(-x, 0.08333333333333333, fma(pow(x, 3.0), 0.009722222222222222, (0.5 / x))) * (exp(x) + 1.0));
}
return temp;
}




Bits error versus x
Results
| Original | 40.5 |
|---|---|
| Target | 40.1 |
| Herbie | 0.7 |
if (exp x) < 0.018436024377239738Initial program 0.0
if 0.018436024377239738 < (exp x) Initial program 61.4
rmApplied flip--61.4
Applied associate-/r/61.4
Simplified61.3
Taylor expanded around 0 1.1
Simplified1.1
Final simplification0.7
herbie shell --seed 2020049 +o rules:numerics
(FPCore (x)
:name "expq2 (section 3.11)"
:precision binary64
:herbie-target
(/ 1 (- 1 (exp (- x))))
(/ (exp x) (- (exp x) 1)))