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




Bits error versus a




Bits error versus b
Results
| Original | 0.7 |
|---|---|
| Target | 0.0 |
| Herbie | 0.7 |
Initial program 0.7
Applied egg-rr0.7
Final simplification0.7
herbie shell --seed 2022166
(FPCore (a b)
:name "Quotient of sum of exps"
:precision binary64
:herbie-target
(/ 1.0 (+ 1.0 (exp (- b a))))
(/ (exp a) (+ (exp a) (exp b))))