\frac{e^{x} - 1}{x}\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\mathsf{expm1}\left(x\right)}{x}\right)\right)double f(double x) {
double r3385625 = x;
double r3385626 = exp(r3385625);
double r3385627 = 1.0;
double r3385628 = r3385626 - r3385627;
double r3385629 = r3385628 / r3385625;
return r3385629;
}
double f(double x) {
double r3385630 = x;
double r3385631 = expm1(r3385630);
double r3385632 = r3385631 / r3385630;
double r3385633 = expm1(r3385632);
double r3385634 = log1p(r3385633);
return r3385634;
}




Bits error versus x
Results
| Original | 40.4 |
|---|---|
| Target | 39.6 |
| Herbie | 0.2 |
Initial program 40.4
Simplified0.0
rmApplied log1p-expm1-u0.2
Final simplification0.2
herbie shell --seed 2019134 +o rules:numerics
(FPCore (x)
:name "Kahan's exp quotient"
:herbie-target
(if (and (< x 1) (> x -1)) (/ (- (exp x) 1) (log (exp x))) (/ (- (exp x) 1) x))
(/ (- (exp x) 1) x))