\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{\frac{1}{\sqrt[3]{1 - e^{\log 1 - x}}}}{\sqrt[3]{1 - e^{\log 1 - x}}}}{\sqrt[3]{1 - e^{\log 1 - x}}}\\
\end{array}double f(double x) {
double r369 = x;
double r370 = exp(r369);
double r371 = 1.0;
double r372 = r370 - r371;
double r373 = r370 / r372;
return r373;
}
double f(double x) {
double r374 = x;
double r375 = -0.0007345308468624735;
bool r376 = r374 <= r375;
double r377 = exp(r374);
double r378 = 1.0;
double r379 = -r378;
double r380 = r374 + r374;
double r381 = exp(r380);
double r382 = fma(r379, r378, r381);
double r383 = r377 + r378;
double r384 = r382 / r383;
double r385 = r377 / r384;
double r386 = 0.0017789298620281822;
bool r387 = r374 <= r386;
double r388 = 0.08333333333333333;
double r389 = 1.0;
double r390 = r389 / r374;
double r391 = fma(r388, r374, r390);
double r392 = 0.5;
double r393 = r391 + r392;
double r394 = log(r378);
double r395 = r394 - r374;
double r396 = exp(r395);
double r397 = r389 - r396;
double r398 = cbrt(r397);
double r399 = r389 / r398;
double r400 = r399 / r398;
double r401 = r400 / r398;
double r402 = r387 ? r393 : r401;
double r403 = r376 ? r385 : r402;
return r403;
}




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 associate-/r*0.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)))