\frac{e^{a}}{e^{a} + e^{b}}\mathsf{expm1}\left(\mathsf{log1p}\left(e^{a - \log \left(e^{a} + e^{b}\right)}\right)\right)double code(double a, double b) {
return (exp(a) / (exp(a) + exp(b)));
}
double code(double a, double b) {
return expm1(log1p(exp((a - log((exp(a) + exp(b)))))));
}




Bits error versus a




Bits error versus b
Results
| Original | 0.6 |
|---|---|
| Target | 0.0 |
| Herbie | 0.5 |
Initial program 0.6
rmApplied add-exp-log0.6
Applied div-exp0.5
rmApplied expm1-log1p-u0.5
Final simplification0.5
herbie shell --seed 2020056 +o rules:numerics
(FPCore (a b)
:name "Quotient of sum of exps"
:precision binary64
:herbie-target
(/ 1 (+ 1 (exp (- b a))))
(/ (exp a) (+ (exp a) (exp b))))