?

Average Accuracy: 98.7% → 99.0%
Time: 5.5s
Precision: binary64
Cost: 25920

?

\[\frac{e^{a}}{e^{a} + e^{b}} \]
\[e^{a - \log \left(e^{a} + e^{b}\right)} \]
(FPCore (a b) :precision binary64 (/ (exp a) (+ (exp a) (exp b))))
(FPCore (a b) :precision binary64 (exp (- a (log (+ (exp a) (exp b))))))
double code(double a, double b) {
	return exp(a) / (exp(a) + exp(b));
}
double code(double a, double b) {
	return exp((a - log((exp(a) + exp(b)))));
}
real(8) function code(a, b)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    code = exp(a) / (exp(a) + exp(b))
end function
real(8) function code(a, b)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    code = exp((a - log((exp(a) + exp(b)))))
end function
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.exp((a - Math.log((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.exp((a - math.log((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 exp(Float64(a - log(Float64(exp(a) + exp(b)))))
end
function tmp = code(a, b)
	tmp = exp(a) / (exp(a) + exp(b));
end
function tmp = code(a, b)
	tmp = exp((a - log((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[(a - N[Log[N[(N[Exp[a], $MachinePrecision] + N[Exp[b], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\frac{e^{a}}{e^{a} + e^{b}}
e^{a - \log \left(e^{a} + e^{b}\right)}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original98.7%
Target100.0%
Herbie99.0%
\[\frac{1}{1 + e^{b - a}} \]

Derivation?

  1. Initial program 98.7%

    \[\frac{e^{a}}{e^{a} + e^{b}} \]
  2. Applied egg-rr99.0%

    \[\leadsto \color{blue}{e^{a - \log \left(e^{a} + e^{b}\right)}} \]
  3. Final simplification99.0%

    \[\leadsto e^{a - \log \left(e^{a} + e^{b}\right)} \]

Alternatives

Alternative 1
Accuracy81.3%
Cost19849
\[\begin{array}{l} \mathbf{if}\;e^{b} \leq 1 \lor \neg \left(e^{b} \leq 3.5 \cdot 10^{+38}\right):\\ \;\;\;\;\frac{1}{e^{b} + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{1 + e^{-a}}\\ \end{array} \]
Alternative 2
Accuracy98.7%
Cost19520
\[\frac{e^{a}}{e^{a} + e^{b}} \]
Alternative 3
Accuracy98.2%
Cost13252
\[\begin{array}{l} \mathbf{if}\;e^{a} \leq 0.5:\\ \;\;\;\;e^{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{e^{b} + 1}\\ \end{array} \]
Alternative 4
Accuracy61.2%
Cost6992
\[\begin{array}{l} \mathbf{if}\;b \leq -2.35 \cdot 10^{-55}:\\ \;\;\;\;e^{a}\\ \mathbf{elif}\;b \leq 1.22 \cdot 10^{-265}:\\ \;\;\;\;\frac{1}{2 - a}\\ \mathbf{elif}\;b \leq 2.1 \cdot 10^{-240}:\\ \;\;\;\;e^{a}\\ \mathbf{elif}\;b \leq 1.02 \cdot 10^{-53}:\\ \;\;\;\;0.5 + a \cdot 0.25\\ \mathbf{else}:\\ \;\;\;\;e^{a}\\ \end{array} \]
Alternative 5
Accuracy79.0%
Cost6724
\[\begin{array}{l} \mathbf{if}\;b \leq -1.05:\\ \;\;\;\;e^{a}\\ \mathbf{else}:\\ \;\;\;\;e^{a} \cdot 0.5\\ \end{array} \]
Alternative 6
Accuracy39.5%
Cost320
\[0.5 + a \cdot 0.25 \]
Alternative 7
Accuracy40.1%
Cost320
\[\frac{1}{2 - a} \]
Alternative 8
Accuracy39.3%
Cost64
\[0.5 \]

Error

Reproduce?

herbie shell --seed 2023125 
(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))))