Average Error: 0.7 → 0.6
Time: 6.6s
Precision: binary64
\[\frac{e^{a}}{e^{a} + e^{b}} \]
\[e^{a - \sqrt{{\log \left(e^{a} + e^{b}\right)}^{2}}} \]
(FPCore (a b) :precision binary64 (/ (exp a) (+ (exp a) (exp b))))
(FPCore (a b)
 :precision binary64
 (exp (- a (sqrt (pow (log (+ (exp a) (exp b))) 2.0)))))
double code(double a, double b) {
	return exp(a) / (exp(a) + exp(b));
}
double code(double a, double b) {
	return exp((a - sqrt(pow(log((exp(a) + exp(b))), 2.0))));
}
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 - sqrt((log((exp(a) + exp(b))) ** 2.0d0))))
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.sqrt(Math.pow(Math.log((Math.exp(a) + Math.exp(b))), 2.0))));
}
def code(a, b):
	return math.exp(a) / (math.exp(a) + math.exp(b))
def code(a, b):
	return math.exp((a - math.sqrt(math.pow(math.log((math.exp(a) + math.exp(b))), 2.0))))
function code(a, b)
	return Float64(exp(a) / Float64(exp(a) + exp(b)))
end
function code(a, b)
	return exp(Float64(a - sqrt((log(Float64(exp(a) + exp(b))) ^ 2.0))))
end
function tmp = code(a, b)
	tmp = exp(a) / (exp(a) + exp(b));
end
function tmp = code(a, b)
	tmp = exp((a - sqrt((log((exp(a) + exp(b))) ^ 2.0))));
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[Sqrt[N[Power[N[Log[N[(N[Exp[a], $MachinePrecision] + N[Exp[b], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\frac{e^{a}}{e^{a} + e^{b}}
e^{a - \sqrt{{\log \left(e^{a} + e^{b}\right)}^{2}}}

Error

Bits error versus a

Bits error versus b

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original0.7
Target0.0
Herbie0.6
\[\frac{1}{1 + e^{b - a}} \]

Derivation

  1. Initial program 0.7

    \[\frac{e^{a}}{e^{a} + e^{b}} \]
  2. Applied egg-rr0.6

    \[\leadsto \color{blue}{e^{a - \log \left(e^{a} + e^{b}\right)}} \]
  3. Applied egg-rr0.6

    \[\leadsto e^{a - \color{blue}{\sqrt{{\log \left(e^{a} + e^{b}\right)}^{2}}}} \]
  4. Final simplification0.6

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

Reproduce

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