\frac{e^{x} - 1}{x}\begin{array}{l}
\mathbf{if}\;x \le -1.9141971874233585 \cdot 10^{-4}:\\
\;\;\;\;\frac{\log \left(e^{e^{x} - 1}\right)}{x}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{6}, {x}^{2}, \mathsf{fma}\left(\frac{1}{2}, x, 1\right)\right)\\
\end{array}double f(double x) {
double r75104 = x;
double r75105 = exp(r75104);
double r75106 = 1.0;
double r75107 = r75105 - r75106;
double r75108 = r75107 / r75104;
return r75108;
}
double f(double x) {
double r75109 = x;
double r75110 = -0.00019141971874233585;
bool r75111 = r75109 <= r75110;
double r75112 = exp(r75109);
double r75113 = 1.0;
double r75114 = r75112 - r75113;
double r75115 = exp(r75114);
double r75116 = log(r75115);
double r75117 = r75116 / r75109;
double r75118 = 0.16666666666666666;
double r75119 = 2.0;
double r75120 = pow(r75109, r75119);
double r75121 = 0.5;
double r75122 = 1.0;
double r75123 = fma(r75121, r75109, r75122);
double r75124 = fma(r75118, r75120, r75123);
double r75125 = r75111 ? r75117 : r75124;
return r75125;
}




Bits error versus x
| Original | 39.8 |
|---|---|
| Target | 40.2 |
| Herbie | 0.4 |
if x < -0.00019141971874233585Initial program 0.0
rmApplied add-log-exp0.0
Applied add-log-exp0.1
Applied diff-log0.1
Simplified0.1
if -0.00019141971874233585 < x Initial program 60.1
Taylor expanded around 0 0.5
Simplified0.5
Final simplification0.4
herbie shell --seed 2020060 +o rules:numerics
(FPCore (x)
:name "Kahan's exp quotient"
:precision binary64
:herbie-target
(if (and (< x 1) (> x -1)) (/ (- (exp x) 1) (log (exp x))) (/ (- (exp x) 1) x))
(/ (- (exp x) 1) x))