\frac{e^{a}}{e^{a} + e^{b}}\begin{array}{l}
\mathbf{if}\;a \leq -2277.436057145762:\\
\;\;\;\;0\\
\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 (<= a -2277.436057145762) 0.0 (/ 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 (a <= -2277.436057145762) {
tmp = 0.0;
} 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.8 |
| Alternative 1 | |
|---|---|
| Error | 0.7 |
| Cost | 19520 |
| Alternative 2 | |
|---|---|
| Error | 12.3 |
| Cost | 1090 |
| Alternative 3 | |
|---|---|
| Error | 12.3 |
| Cost | 962 |
| Alternative 4 | |
|---|---|
| Error | 22.4 |
| Cost | 385 |
| Alternative 5 | |
|---|---|
| Error | 46.5 |
| Cost | 64 |

if a < -2277.4360571457619Initial program 0.2
if -2277.4360571457619 < a Initial program 0.8
Taylor expanded around 0 1.1
Simplified1.1
Final simplification0.8
herbie shell --seed 2021044
(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))))