\frac{e^{x}}{e^{x} - 1}\begin{array}{l}
\mathbf{if}\;x \le -0.0018711434362285975:\\
\;\;\;\;\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}}}\\
\mathbf{elif}\;x \le 9.641487078301664 \cdot 10^{-4}:\\
\;\;\;\;\frac{1}{2} + \left(\frac{1}{12} \cdot x + \frac{1}{x}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{1 - \frac{{\left(e^{2}\right)}^{\left(\log 1 - x\right)}}{1}} \cdot \left(1 + e^{\log 1 - x}\right)\\
\end{array}double f(double x) {
double r401 = x;
double r402 = exp(r401);
double r403 = 1.0;
double r404 = r402 - r403;
double r405 = r402 / r404;
return r405;
}
double f(double x) {
double r406 = x;
double r407 = -0.0018711434362285975;
bool r408 = r406 <= r407;
double r409 = 1.0;
double r410 = 1.0;
double r411 = log(r410);
double r412 = r411 - r406;
double r413 = exp(r412);
double r414 = r409 - r413;
double r415 = cbrt(r414);
double r416 = r409 / r415;
double r417 = r416 / r415;
double r418 = r417 * r416;
double r419 = 0.0009641487078301664;
bool r420 = r406 <= r419;
double r421 = 0.5;
double r422 = 0.08333333333333333;
double r423 = r422 * r406;
double r424 = r409 / r406;
double r425 = r423 + r424;
double r426 = r421 + r425;
double r427 = 2.0;
double r428 = exp(r427);
double r429 = pow(r428, r412);
double r430 = r429 / r409;
double r431 = r409 - r430;
double r432 = r409 / r431;
double r433 = r409 + r413;
double r434 = r432 * r433;
double r435 = r420 ? r426 : r434;
double r436 = r408 ? r418 : r435;
return r436;
}




Bits error versus x
Results
| Original | 40.3 |
|---|---|
| Target | 39.8 |
| Herbie | 0.0 |
if x < -0.0018711434362285975Initial program 0.0
rmApplied clear-num0.0
Simplified0.0
rmApplied add-exp-log0.0
Applied div-exp0.0
rmApplied add-cube-cbrt0.0
Applied add-cube-cbrt0.0
Applied times-frac0.0
Simplified0.0
Simplified0.0
if -0.0018711434362285975 < x < 0.0009641487078301664Initial program 62.4
Taylor expanded around 0 0.0
if 0.0009641487078301664 < x Initial program 35.8
rmApplied clear-num35.8
Simplified1.1
rmApplied add-exp-log1.1
Applied div-exp0.7
rmApplied flip--0.7
Applied associate-/r/0.7
Simplified0.6
Final simplification0.0
herbie shell --seed 2020025
(FPCore (x)
:name "expq2 (section 3.11)"
:precision binary64
:herbie-target
(/ 1 (- 1 (exp (- x))))
(/ (exp x) (- (exp x) 1)))