\frac{e^{x} - 1}{x}\begin{array}{l}
\mathbf{if}\;x \le -1.1982150581412934 \cdot 10^{-4}:\\
\;\;\;\;\frac{\frac{\frac{\mathsf{fma}\left(-1, 1, e^{x + x}\right)}{\sqrt{e^{x} + 1}}}{\sqrt{e^{x} + 1}}}{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 code(double x) {
return ((exp(x) - 1.0) / x);
}
double code(double x) {
double temp;
if ((x <= -0.00011982150581412934)) {
temp = (((fma(-1.0, 1.0, exp((x + x))) / sqrt((exp(x) + 1.0))) / sqrt((exp(x) + 1.0))) / x);
} else {
temp = (fma(0.5, pow(x, 2.0), fma(0.16666666666666666, pow(x, 3.0), x)) / x);
}
return temp;
}




Bits error versus x
Results
| Original | 39.6 |
|---|---|
| Target | 40.1 |
| Herbie | 0.3 |
if x < -0.00011982150581412934Initial program 0.1
rmApplied flip--0.1
Simplified0.0
rmApplied add-sqr-sqrt0.0
Applied associate-/r*0.0
if -0.00011982150581412934 < x Initial program 60.2
Taylor expanded around 0 0.5
Simplified0.5
Final simplification0.3
herbie shell --seed 2020065 +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))