\frac{e^{x} - 1}{x}\begin{array}{l}
\mathbf{if}\;x \le -1.183559032193283916444340175821992033889 \cdot 10^{-4}:\\
\;\;\;\;\frac{\log \left(e^{e^{x} - 1}\right)}{x}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot x\right) + 1\\
\end{array}double f(double x) {
double r57586 = x;
double r57587 = exp(r57586);
double r57588 = 1.0;
double r57589 = r57587 - r57588;
double r57590 = r57589 / r57586;
return r57590;
}
double f(double x) {
double r57591 = x;
double r57592 = -0.00011835590321932839;
bool r57593 = r57591 <= r57592;
double r57594 = exp(r57591);
double r57595 = 1.0;
double r57596 = r57594 - r57595;
double r57597 = exp(r57596);
double r57598 = log(r57597);
double r57599 = r57598 / r57591;
double r57600 = 0.5;
double r57601 = 0.16666666666666666;
double r57602 = r57601 * r57591;
double r57603 = r57600 + r57602;
double r57604 = r57591 * r57603;
double r57605 = 1.0;
double r57606 = r57604 + r57605;
double r57607 = r57593 ? r57599 : r57606;
return r57607;
}




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