\frac{e^{x} - 1}{x}\begin{array}{l}
\mathbf{if}\;x \le -1.90730229533167929337200696693344070809 \cdot 10^{-4}:\\
\;\;\;\;\frac{\log \left(e^{e^{x} - 1}\right)}{x}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(x, \mathsf{fma}\left(\frac{1}{6}, x, \frac{1}{2}\right), 1\right)} \cdot \sqrt[3]{{\left(\mathsf{fma}\left(x, \mathsf{fma}\left(\frac{5}{96}, x, \frac{1}{4}\right), 1\right)\right)}^{3}}\\
\end{array}double f(double x) {
double r100721 = x;
double r100722 = exp(r100721);
double r100723 = 1.0;
double r100724 = r100722 - r100723;
double r100725 = r100724 / r100721;
return r100725;
}
double f(double x) {
double r100726 = x;
double r100727 = -0.00019073022953316793;
bool r100728 = r100726 <= r100727;
double r100729 = exp(r100726);
double r100730 = 1.0;
double r100731 = r100729 - r100730;
double r100732 = exp(r100731);
double r100733 = log(r100732);
double r100734 = r100733 / r100726;
double r100735 = 0.16666666666666666;
double r100736 = 0.5;
double r100737 = fma(r100735, r100726, r100736);
double r100738 = 1.0;
double r100739 = fma(r100726, r100737, r100738);
double r100740 = sqrt(r100739);
double r100741 = 0.052083333333333336;
double r100742 = 0.25;
double r100743 = fma(r100741, r100726, r100742);
double r100744 = fma(r100726, r100743, r100738);
double r100745 = 3.0;
double r100746 = pow(r100744, r100745);
double r100747 = cbrt(r100746);
double r100748 = r100740 * r100747;
double r100749 = r100728 ? r100734 : r100748;
return r100749;
}




Bits error versus x
| Original | 39.6 |
|---|---|
| Target | 40.0 |
| Herbie | 0.3 |
if x < -0.00019073022953316793Initial program 0.0
rmApplied add-log-exp0.0
Applied add-log-exp0.1
Applied diff-log0.1
Simplified0.1
if -0.00019073022953316793 < x Initial program 60.1
Taylor expanded around 0 0.4
Simplified0.4
rmApplied add-sqr-sqrt0.4
rmApplied add-cbrt-cube0.4
Simplified0.4
Taylor expanded around 0 0.4
Simplified0.4
Final simplification0.3
herbie shell --seed 2019323 +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))