\frac{e^{x}}{e^{x} - 1}\begin{array}{l}
\mathbf{if}\;x \le -0.00171217474424922053:\\
\;\;\;\;\frac{1}{\log \left(e^{1 - e^{\log 1 - x}}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2} + \left(\frac{1}{12} \cdot x + \frac{1}{x}\right)\\
\end{array}double f(double x) {
double r95263 = x;
double r95264 = exp(r95263);
double r95265 = 1.0;
double r95266 = r95264 - r95265;
double r95267 = r95264 / r95266;
return r95267;
}
double f(double x) {
double r95268 = x;
double r95269 = -0.0017121747442492205;
bool r95270 = r95268 <= r95269;
double r95271 = 1.0;
double r95272 = 1.0;
double r95273 = log(r95272);
double r95274 = r95273 - r95268;
double r95275 = exp(r95274);
double r95276 = r95271 - r95275;
double r95277 = exp(r95276);
double r95278 = log(r95277);
double r95279 = r95271 / r95278;
double r95280 = 0.5;
double r95281 = 0.08333333333333333;
double r95282 = r95281 * r95268;
double r95283 = r95271 / r95268;
double r95284 = r95282 + r95283;
double r95285 = r95280 + r95284;
double r95286 = r95270 ? r95279 : r95285;
return r95286;
}




Bits error versus x
Results
| Original | 41.5 |
|---|---|
| Target | 41.2 |
| Herbie | 0.8 |
if x < -0.0017121747442492205Initial program 0.0
rmApplied clear-num0.0
Simplified0.0
rmApplied add-exp-log0.0
Applied div-exp0.0
rmApplied add-log-exp0.7
Applied add-log-exp0.7
Applied diff-log0.7
Simplified0.7
if -0.0017121747442492205 < x Initial program 61.9
Taylor expanded around 0 0.8
Final simplification0.8
herbie shell --seed 2020039
(FPCore (x)
:name "expq2 (section 3.11)"
:precision binary64
:herbie-target
(/ 1 (- 1 (exp (- x))))
(/ (exp x) (- (exp x) 1)))