(FPCore (x) :precision binary64 (/ (- (exp x) 1.0) x))
(FPCore (x) :precision binary64 (pow (/ x (expm1 x)) -1.0))
double code(double x) {
return (exp(x) - 1.0) / x;
}
double code(double x) {
return pow((x / expm1(x)), -1.0);
}
public static double code(double x) {
return (Math.exp(x) - 1.0) / x;
}
public static double code(double x) {
return Math.pow((x / Math.expm1(x)), -1.0);
}
def code(x): return (math.exp(x) - 1.0) / x
def code(x): return math.pow((x / math.expm1(x)), -1.0)
function code(x) return Float64(Float64(exp(x) - 1.0) / x) end
function code(x) return Float64(x / expm1(x)) ^ -1.0 end
code[x_] := N[(N[(N[Exp[x], $MachinePrecision] - 1.0), $MachinePrecision] / x), $MachinePrecision]
code[x_] := N[Power[N[(x / N[(Exp[x] - 1), $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision]
\frac{e^{x} - 1}{x}
{\left(\frac{x}{\mathsf{expm1}\left(x\right)}\right)}^{-1}




Bits error versus x
Results
| Original | 39.9 |
|---|---|
| Target | 40.3 |
| Herbie | 0.0 |
Initial program 39.9
Simplified0.0
Applied egg-rr0.0
Final simplification0.0
herbie shell --seed 2022150
(FPCore (x)
:name "Kahan's exp quotient"
:precision binary64
:herbie-target
(if (and (< x 1.0) (> x -1.0)) (/ (- (exp x) 1.0) (log (exp x))) (/ (- (exp x) 1.0) x))
(/ (- (exp x) 1.0) x))