\frac{e^{x}}{e^{x} - 1}\begin{array}{l}
\mathbf{if}\;x \le -0.002237729744276147157006073840079807268921:\\
\;\;\;\;\frac{1}{1 - e^{\log 1 - x}}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{12}, x, \frac{1}{x}\right) + \frac{1}{2}\\
\end{array}double f(double x) {
double r51979 = x;
double r51980 = exp(r51979);
double r51981 = 1.0;
double r51982 = r51980 - r51981;
double r51983 = r51980 / r51982;
return r51983;
}
double f(double x) {
double r51984 = x;
double r51985 = -0.002237729744276147;
bool r51986 = r51984 <= r51985;
double r51987 = 1.0;
double r51988 = 1.0;
double r51989 = log(r51988);
double r51990 = r51989 - r51984;
double r51991 = exp(r51990);
double r51992 = r51987 - r51991;
double r51993 = r51987 / r51992;
double r51994 = 0.08333333333333333;
double r51995 = r51987 / r51984;
double r51996 = fma(r51994, r51984, r51995);
double r51997 = 0.5;
double r51998 = r51996 + r51997;
double r51999 = r51986 ? r51993 : r51998;
return r51999;
}




Bits error versus x
| Original | 40.9 |
|---|---|
| Target | 40.4 |
| Herbie | 0.6 |
if x < -0.002237729744276147Initial program 0.0
rmApplied clear-num0.0
Simplified0.0
rmApplied add-exp-log0.0
Applied div-exp0.0
if -0.002237729744276147 < x Initial program 62.1
Taylor expanded around 0 0.9
Simplified0.9
Final simplification0.6
herbie shell --seed 2020002 +o rules:numerics
(FPCore (x)
:name "expq2 (section 3.11)"
:precision binary64
:herbie-target
(/ 1 (- 1 (exp (- x))))
(/ (exp x) (- (exp x) 1)))