\frac{e^{x}}{e^{x} - 1.0}\begin{array}{l}
\mathbf{if}\;x \le -0.043762652068368615:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{e^{x}}{e^{x} - 1.0}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, \frac{1}{12}, \frac{1}{2}\right) + \frac{1}{x}\\
\end{array}double f(double x) {
double r4218134 = x;
double r4218135 = exp(r4218134);
double r4218136 = 1.0;
double r4218137 = r4218135 - r4218136;
double r4218138 = r4218135 / r4218137;
return r4218138;
}
double f(double x) {
double r4218139 = x;
double r4218140 = -0.043762652068368615;
bool r4218141 = r4218139 <= r4218140;
double r4218142 = exp(r4218139);
double r4218143 = 1.0;
double r4218144 = r4218142 - r4218143;
double r4218145 = r4218142 / r4218144;
double r4218146 = expm1(r4218145);
double r4218147 = log1p(r4218146);
double r4218148 = 0.08333333333333333;
double r4218149 = 0.5;
double r4218150 = fma(r4218139, r4218148, r4218149);
double r4218151 = 1.0;
double r4218152 = r4218151 / r4218139;
double r4218153 = r4218150 + r4218152;
double r4218154 = r4218141 ? r4218147 : r4218153;
return r4218154;
}




Bits error versus x
| Original | 40.4 |
|---|---|
| Target | 40.0 |
| Herbie | 0.7 |
if x < -0.043762652068368615Initial program 0.0
rmApplied add-sqr-sqrt0.0
Applied add-sqr-sqrt0.0
Applied difference-of-squares0.0
Applied *-un-lft-identity0.0
Applied times-frac0.0
rmApplied log1p-expm1-u0.0
Simplified0.0
if -0.043762652068368615 < x Initial program 61.7
Taylor expanded around 0 1.2
Simplified1.2
Taylor expanded around 0 1.0
Simplified1.0
Final simplification0.7
herbie shell --seed 2019165 +o rules:numerics
(FPCore (x)
:name "expq2 (section 3.11)"
:herbie-target
(/ 1.0 (- 1.0 (exp (- x))))
(/ (exp x) (- (exp x) 1.0)))