\frac{e^{x} - 1}{x}\begin{array}{l}
\mathbf{if}\;x \le -1.012327742145682 \cdot 10^{-4}:\\
\;\;\;\;\frac{1}{x} \cdot \left(e^{x} - 1\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{6}, {x}^{2}, \mathsf{fma}\left(\frac{1}{2}, x, 1\right)\right)\\
\end{array}double f(double x) {
double r73773 = x;
double r73774 = exp(r73773);
double r73775 = 1.0;
double r73776 = r73774 - r73775;
double r73777 = r73776 / r73773;
return r73777;
}
double f(double x) {
double r73778 = x;
double r73779 = -0.0001012327742145682;
bool r73780 = r73778 <= r73779;
double r73781 = 1.0;
double r73782 = r73781 / r73778;
double r73783 = exp(r73778);
double r73784 = 1.0;
double r73785 = r73783 - r73784;
double r73786 = r73782 * r73785;
double r73787 = 0.16666666666666666;
double r73788 = 2.0;
double r73789 = pow(r73778, r73788);
double r73790 = 0.5;
double r73791 = fma(r73790, r73778, r73781);
double r73792 = fma(r73787, r73789, r73791);
double r73793 = r73780 ? r73786 : r73792;
return r73793;
}




Bits error versus x
| Original | 40.0 |
|---|---|
| Target | 40.5 |
| Herbie | 0.3 |
if x < -0.0001012327742145682Initial program 0.1
rmApplied div-sub0.1
rmApplied div-inv0.1
Applied div-inv0.1
Applied distribute-rgt-out--0.1
if -0.0001012327742145682 < x Initial program 60.2
Taylor expanded around 0 0.5
Simplified0.5
Final simplification0.3
herbie shell --seed 2020035 +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))