\frac{e^{x}}{e^{x} - 1}\begin{array}{l}
\mathbf{if}\;x \le -7.3453084686247354 \cdot 10^{-4}:\\
\;\;\;\;\frac{e^{x}}{\frac{\mathsf{fma}\left(-1, 1, e^{x + x}\right)}{e^{x} + 1}}\\
\mathbf{elif}\;x \le 0.0017789298620281822:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{12}, x, \frac{1}{x}\right) + \frac{1}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{\sqrt[3]{1 - e^{\log 1 - x}}}}{\sqrt[3]{1 - e^{\log 1 - x}}} \cdot \frac{1}{\sqrt[3]{1 - e^{\log 1 - x}}}\\
\end{array}double f(double x) {
double r107550 = x;
double r107551 = exp(r107550);
double r107552 = 1.0;
double r107553 = r107551 - r107552;
double r107554 = r107551 / r107553;
return r107554;
}
double f(double x) {
double r107555 = x;
double r107556 = -0.0007345308468624735;
bool r107557 = r107555 <= r107556;
double r107558 = exp(r107555);
double r107559 = 1.0;
double r107560 = -r107559;
double r107561 = r107555 + r107555;
double r107562 = exp(r107561);
double r107563 = fma(r107560, r107559, r107562);
double r107564 = r107558 + r107559;
double r107565 = r107563 / r107564;
double r107566 = r107558 / r107565;
double r107567 = 0.0017789298620281822;
bool r107568 = r107555 <= r107567;
double r107569 = 0.08333333333333333;
double r107570 = 1.0;
double r107571 = r107570 / r107555;
double r107572 = fma(r107569, r107555, r107571);
double r107573 = 0.5;
double r107574 = r107572 + r107573;
double r107575 = log(r107559);
double r107576 = r107575 - r107555;
double r107577 = exp(r107576);
double r107578 = r107570 - r107577;
double r107579 = cbrt(r107578);
double r107580 = r107570 / r107579;
double r107581 = r107580 / r107579;
double r107582 = r107581 * r107580;
double r107583 = r107568 ? r107574 : r107582;
double r107584 = r107557 ? r107566 : r107583;
return r107584;
}




Bits error versus x
| Original | 40.3 |
|---|---|
| Target | 39.8 |
| Herbie | 0.0 |
if x < -0.0007345308468624735Initial program 0.0
rmApplied flip--0.0
Simplified0.0
if -0.0007345308468624735 < x < 0.0017789298620281822Initial program 62.3
Taylor expanded around 0 0.0
Simplified0.0
if 0.0017789298620281822 < x Initial program 37.2
rmApplied clear-num37.2
Simplified0.8
rmApplied add-exp-log0.8
Applied div-exp0.5
rmApplied add-cube-cbrt0.7
Applied add-cube-cbrt0.7
Applied times-frac0.7
Simplified0.7
Simplified0.7
Final simplification0.0
herbie shell --seed 2020025 +o rules:numerics
(FPCore (x)
:name "expq2 (section 3.11)"
:precision binary64
:herbie-target
(/ 1 (- 1 (exp (- x))))
(/ (exp x) (- (exp x) 1)))