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




Bits error versus x
Results
| Original | 41.5 |
|---|---|
| Target | 41.0 |
| Herbie | 0.0 |
Initial program 41.5
Simplified0.5
Applied egg-rr0.5
Taylor expanded in x around inf 41.5
Simplified0.0
Taylor expanded in x around inf 41.0
Simplified0.0
Final simplification0.0
herbie shell --seed 2022150
(FPCore (x)
:name "expq2 (section 3.11)"
:precision binary64
:herbie-target
(/ 1.0 (- 1.0 (exp (- x))))
(/ (exp x) (- (exp x) 1.0)))