Average Error: 0.6 → 0.0
Time: 2.5s
Precision: binary64
\[\frac{e^{a}}{e^{a} + e^{b}}\]
\[\frac{-1}{-1 - e^{b - a}}\]
\frac{e^{a}}{e^{a} + e^{b}}
\frac{-1}{-1 - e^{b - a}}
(FPCore (a b) :precision binary64 (/ (exp a) (+ (exp a) (exp b))))
(FPCore (a b) :precision binary64 (/ -1.0 (- -1.0 (exp (- b a)))))
double code(double a, double b) {
	return exp(a) / (exp(a) + exp(b));
}
double code(double a, double b) {
	return -1.0 / (-1.0 - exp(b - a));
}

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.6
Target0.0
Herbie0.0
\[\frac{1}{1 + e^{b - a}}\]

Derivation

  1. Initial program 0.6

    \[\frac{e^{a}}{e^{a} + e^{b}}\]
  2. Using strategy rm
  3. Applied frac-2neg_binary640.6

    \[\leadsto \color{blue}{\frac{-e^{a}}{-\left(e^{a} + e^{b}\right)}}\]
  4. Simplified0.6

    \[\leadsto \frac{-e^{a}}{\color{blue}{\left(-e^{a}\right) - e^{b}}}\]
  5. Taylor expanded around inf 0.6

    \[\leadsto \color{blue}{\frac{e^{a}}{e^{b} + e^{a}}}\]
  6. Simplified0.0

    \[\leadsto \color{blue}{\frac{-1}{-1 - e^{b - a}}}\]
  7. Final simplification0.0

    \[\leadsto \frac{-1}{-1 - e^{b - a}}\]

Alternatives

Reproduce

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