\frac{e^{a}}{e^{a} + e^{b}}\begin{array}{l}
\mathbf{if}\;e^{a} \leq 3.421041865160871 \cdot 10^{+102}:\\
\;\;\;\;\frac{1}{\frac{e^{a} + e^{b}}{e^{a}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{1 + e^{b}}\\
\end{array}(FPCore (a b) :precision binary64 (/ (exp a) (+ (exp a) (exp b))))
(FPCore (a b) :precision binary64 (if (<= (exp a) 3.421041865160871e+102) (/ 1.0 (/ (+ (exp a) (exp b)) (exp a))) (/ 1.0 (+ 1.0 (exp b)))))
double code(double a, double b) {
return exp(a) / (exp(a) + exp(b));
}
double code(double a, double b) {
double tmp;
if (exp(a) <= 3.421041865160871e+102) {
tmp = 1.0 / ((exp(a) + exp(b)) / exp(a));
} else {
tmp = 1.0 / (1.0 + exp(b));
}
return tmp;
}




Bits error versus a




Bits error versus b
Results
| Original | 0.7 |
|---|---|
| Target | 0.0 |
| Herbie | 0.4 |
if (exp.f64 a) < 3.42104186516087124e102Initial program 0.2
rmApplied clear-num_binary64_24640.3
Simplified0.3
if 3.42104186516087124e102 < (exp.f64 a) Initial program 60.7
Taylor expanded around 0 25.1
Final simplification0.4
herbie shell --seed 2021024
(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))))