\frac{e^{x}}{e^{x} - 1}\begin{array}{l}
\mathbf{if}\;x \le -0.0019729997710959393:\\
\;\;\;\;\frac{1}{1 - \frac{1}{e^{x}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x} + \mathsf{fma}\left(\frac{1}{12}, x, \frac{1}{2}\right)\\
\end{array}double f(double x) {
double r1888978 = x;
double r1888979 = exp(r1888978);
double r1888980 = 1.0;
double r1888981 = r1888979 - r1888980;
double r1888982 = r1888979 / r1888981;
return r1888982;
}
double f(double x) {
double r1888983 = x;
double r1888984 = -0.0019729997710959393;
bool r1888985 = r1888983 <= r1888984;
double r1888986 = 1.0;
double r1888987 = exp(r1888983);
double r1888988 = r1888986 / r1888987;
double r1888989 = r1888986 - r1888988;
double r1888990 = r1888986 / r1888989;
double r1888991 = r1888986 / r1888983;
double r1888992 = 0.08333333333333333;
double r1888993 = 0.5;
double r1888994 = fma(r1888992, r1888983, r1888993);
double r1888995 = r1888991 + r1888994;
double r1888996 = r1888985 ? r1888990 : r1888995;
return r1888996;
}




Bits error versus x
| Original | 40.0 |
|---|---|
| Target | 39.5 |
| Herbie | 0.7 |
if x < -0.0019729997710959393Initial program 0.0
rmApplied expm1-log1p-u0.0
Simplified0.0
rmApplied clear-num0.0
Simplified0.0
if -0.0019729997710959393 < x Initial program 60.1
rmApplied expm1-log1p-u60.1
Simplified0.8
Taylor expanded around 0 1.1
Simplified1.1
Final simplification0.7
herbie shell --seed 2019133 +o rules:numerics
(FPCore (x)
:name "expq2 (section 3.11)"
:herbie-target
(/ 1 (- 1 (exp (- x))))
(/ (exp x) (- (exp x) 1)))