Average Error: 0.7 → 0.7
Time: 4.3s
Precision: binary64
\[\frac{e^{a}}{e^{a} + e^{b}} \]
\[\mathsf{log1p}\left(\mathsf{expm1}\left(3 \cdot \left(0.3333333333333333 \cdot \frac{e^{a}}{e^{a} + e^{b}}\right)\right)\right) \]
(FPCore (a b) :precision binary64 (/ (exp a) (+ (exp a) (exp b))))
(FPCore (a b)
 :precision binary64
 (log1p
  (expm1 (* 3.0 (* 0.3333333333333333 (/ (exp a) (+ (exp a) (exp b))))))))
double code(double a, double b) {
	return exp(a) / (exp(a) + exp(b));
}
double code(double a, double b) {
	return log1p(expm1((3.0 * (0.3333333333333333 * (exp(a) / (exp(a) + exp(b)))))));
}
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.log1p(Math.expm1((3.0 * (0.3333333333333333 * (Math.exp(a) / (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.log1p(math.expm1((3.0 * (0.3333333333333333 * (math.exp(a) / (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 log1p(expm1(Float64(3.0 * Float64(0.3333333333333333 * Float64(exp(a) / Float64(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[Log[1 + N[(Exp[N[(3.0 * N[(0.3333333333333333 * N[(N[Exp[a], $MachinePrecision] / N[(N[Exp[a], $MachinePrecision] + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]
\frac{e^{a}}{e^{a} + e^{b}}
\mathsf{log1p}\left(\mathsf{expm1}\left(3 \cdot \left(0.3333333333333333 \cdot \frac{e^{a}}{e^{a} + e^{b}}\right)\right)\right)

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 0.7

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

    \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{e^{a}}{e^{a} + e^{b}}\right)\right)} \]
  3. Applied egg-rr0.8

    \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{\log \left(e^{\frac{e^{a}}{e^{a} + e^{b}}}\right)}\right)\right) \]
  4. Applied egg-rr0.7

    \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{3 \cdot \left(0.3333333333333333 \cdot \frac{e^{a}}{e^{a} + e^{b}}\right)}\right)\right) \]
  5. Final simplification0.7

    \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(3 \cdot \left(0.3333333333333333 \cdot \frac{e^{a}}{e^{a} + e^{b}}\right)\right)\right) \]

Reproduce

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