\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 r69697 = x;
double r69698 = exp(r69697);
double r69699 = 1.0;
double r69700 = r69698 - r69699;
double r69701 = r69700 / r69697;
return r69701;
}
double f(double x) {
double r69702 = x;
double r69703 = -0.00011835590321932839;
bool r69704 = r69702 <= r69703;
double r69705 = exp(r69702);
double r69706 = 1.0;
double r69707 = r69705 - r69706;
double r69708 = exp(r69707);
double r69709 = log(r69708);
double r69710 = r69709 / r69702;
double r69711 = 0.5;
double r69712 = 0.16666666666666666;
double r69713 = r69712 * r69702;
double r69714 = r69711 + r69713;
double r69715 = r69702 * r69714;
double r69716 = 1.0;
double r69717 = r69715 + r69716;
double r69718 = r69704 ? r69710 : r69717;
return r69718;
}




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