\frac{e^{x}}{e^{x} - 1}\begin{array}{l}
\mathbf{if}\;e^{x} \le 0.0:\\
\;\;\;\;\frac{\frac{1}{\sqrt[3]{1 + \frac{\sqrt{1}}{\sqrt{e^{x}}}} \cdot \sqrt[3]{1 + \frac{\sqrt{1}}{\sqrt{e^{x}}}}} \cdot \frac{1}{\sqrt[3]{1 + \frac{\sqrt{1}}{\sqrt{e^{x}}}}}}{1 - \frac{\sqrt{1}}{\sqrt{e^{x}}}}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{12}, x, \frac{1}{x}\right) + \frac{1}{2}\\
\end{array}double f(double x) {
double r67078 = x;
double r67079 = exp(r67078);
double r67080 = 1.0;
double r67081 = r67079 - r67080;
double r67082 = r67079 / r67081;
return r67082;
}
double f(double x) {
double r67083 = x;
double r67084 = exp(r67083);
double r67085 = 0.0;
bool r67086 = r67084 <= r67085;
double r67087 = 1.0;
double r67088 = 1.0;
double r67089 = sqrt(r67088);
double r67090 = sqrt(r67084);
double r67091 = r67089 / r67090;
double r67092 = r67087 + r67091;
double r67093 = cbrt(r67092);
double r67094 = r67093 * r67093;
double r67095 = r67087 / r67094;
double r67096 = r67087 / r67093;
double r67097 = r67095 * r67096;
double r67098 = r67087 - r67091;
double r67099 = r67097 / r67098;
double r67100 = 0.08333333333333333;
double r67101 = r67087 / r67083;
double r67102 = fma(r67100, r67083, r67101);
double r67103 = 0.5;
double r67104 = r67102 + r67103;
double r67105 = r67086 ? r67099 : r67104;
return r67105;
}




Bits error versus x
| Original | 41.3 |
|---|---|
| Target | 40.8 |
| Herbie | 1.0 |
if (exp x) < 0.0Initial program 0
rmApplied clear-num0
Simplified0
rmApplied add-sqr-sqrt0
Applied add-sqr-sqrt0
Applied times-frac0
Applied add-sqr-sqrt0
Applied difference-of-squares0
Applied associate-/r*0
Simplified0
rmApplied add-cube-cbrt0
Applied add-cube-cbrt0
Applied times-frac0
Simplified0
Simplified0
if 0.0 < (exp x) Initial program 61.1
Taylor expanded around 0 1.4
Simplified1.4
Final simplification1.0
herbie shell --seed 2019306 +o rules:numerics
(FPCore (x)
:name "expq2 (section 3.11)"
:precision binary64
:herbie-target
(/ 1 (- 1 (exp (- x))))
(/ (exp x) (- (exp x) 1)))