\frac{e^{x} - 1}{x}\begin{array}{l}
\mathbf{if}\;x \le -1.069605297074794643787457038008881227142 \cdot 10^{-4}:\\
\;\;\;\;\frac{\log \left(e^{e^{x} - 1}\right)}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{1}{2}, {x}^{2}, \mathsf{fma}\left(\frac{1}{6}, {x}^{3}, x\right)\right)}{x}\\
\end{array}double f(double x) {
double r79306 = x;
double r79307 = exp(r79306);
double r79308 = 1.0;
double r79309 = r79307 - r79308;
double r79310 = r79309 / r79306;
return r79310;
}
double f(double x) {
double r79311 = x;
double r79312 = -0.00010696052970747946;
bool r79313 = r79311 <= r79312;
double r79314 = exp(r79311);
double r79315 = 1.0;
double r79316 = r79314 - r79315;
double r79317 = exp(r79316);
double r79318 = log(r79317);
double r79319 = r79318 / r79311;
double r79320 = 0.5;
double r79321 = 2.0;
double r79322 = pow(r79311, r79321);
double r79323 = 0.16666666666666666;
double r79324 = 3.0;
double r79325 = pow(r79311, r79324);
double r79326 = fma(r79323, r79325, r79311);
double r79327 = fma(r79320, r79322, r79326);
double r79328 = r79327 / r79311;
double r79329 = r79313 ? r79319 : r79328;
return r79329;
}




Bits error versus x
| Original | 39.9 |
|---|---|
| Target | 40.4 |
| Herbie | 0.4 |
if x < -0.00010696052970747946Initial program 0.0
rmApplied add-log-exp0.0
Applied add-log-exp0.1
Applied diff-log0.1
Simplified0.0
if -0.00010696052970747946 < x Initial program 60.2
Taylor expanded around 0 0.5
Simplified0.5
Final simplification0.4
herbie shell --seed 2020001 +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))