\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}:\\
\;\;\;\;\mathsf{fma}\left(\frac{5}{96}, {x}^{2}, \mathsf{fma}\left(\frac{1}{4}, x, 1\right)\right) \cdot \sqrt{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \frac{1}{6}, \frac{1}{2}\right), 1\right)}\\
\end{array}double f(double x) {
double r80075 = x;
double r80076 = exp(r80075);
double r80077 = 1.0;
double r80078 = r80076 - r80077;
double r80079 = r80078 / r80075;
return r80079;
}
double f(double x) {
double r80080 = x;
double r80081 = -0.00019073022953316793;
bool r80082 = r80080 <= r80081;
double r80083 = exp(r80080);
double r80084 = 1.0;
double r80085 = r80083 - r80084;
double r80086 = exp(r80085);
double r80087 = log(r80086);
double r80088 = r80087 / r80080;
double r80089 = 0.052083333333333336;
double r80090 = 2.0;
double r80091 = pow(r80080, r80090);
double r80092 = 0.25;
double r80093 = 1.0;
double r80094 = fma(r80092, r80080, r80093);
double r80095 = fma(r80089, r80091, r80094);
double r80096 = 0.16666666666666666;
double r80097 = 0.5;
double r80098 = fma(r80080, r80096, r80097);
double r80099 = fma(r80080, r80098, r80093);
double r80100 = sqrt(r80099);
double r80101 = r80095 * r80100;
double r80102 = r80082 ? r80088 : r80101;
return r80102;
}




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
Simplified0.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))