\frac{e^{x}}{e^{x} - 1}\begin{array}{l}
\mathbf{if}\;x \le -0.0021727830323339213:\\
\;\;\;\;\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 r85179 = x;
double r85180 = exp(r85179);
double r85181 = 1.0;
double r85182 = r85180 - r85181;
double r85183 = r85180 / r85182;
return r85183;
}
double f(double x) {
double r85184 = x;
double r85185 = -0.0021727830323339213;
bool r85186 = r85184 <= r85185;
double r85187 = 1.0;
double r85188 = 1.0;
double r85189 = log(r85188);
double r85190 = r85189 - r85184;
double r85191 = exp(r85190);
double r85192 = r85187 - r85191;
double r85193 = r85187 / r85192;
double r85194 = 0.08333333333333333;
double r85195 = r85187 / r85184;
double r85196 = fma(r85194, r85184, r85195);
double r85197 = 0.5;
double r85198 = r85196 + r85197;
double r85199 = r85186 ? r85193 : r85198;
return r85199;
}




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