Average Error: 0.6 → 0.6
Time: 3.3s
Precision: binary64
\[\frac{e^{a}}{e^{a} + e^{b}}\]
\[{e}^{\left(a - \log \left(e^{b} + e^{a}\right)\right)}\]
\frac{e^{a}}{e^{a} + e^{b}}
{e}^{\left(a - \log \left(e^{b} + e^{a}\right)\right)}
(FPCore (a b) :precision binary64 (/ (exp a) (+ (exp a) (exp b))))
(FPCore (a b) :precision binary64 (pow E (- a (log (+ (exp b) (exp a))))))
double code(double a, double b) {
	return exp(a) / (exp(a) + exp(b));
}
double code(double a, double b) {
	return pow(((double) M_E), (a - log(exp(b) + exp(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.6
\[\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 add-exp-log_binary640.6

    \[\leadsto \frac{e^{a}}{\color{blue}{e^{\log \left(e^{a} + e^{b}\right)}}}\]
  4. Applied div-exp_binary640.5

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

    \[\leadsto e^{\color{blue}{a - \log \left(e^{b} + e^{a}\right)}}\]
  6. Using strategy rm
  7. Applied *-un-lft-identity_binary640.5

    \[\leadsto e^{\color{blue}{1 \cdot \left(a - \log \left(e^{b} + e^{a}\right)\right)}}\]
  8. Applied exp-prod_binary640.6

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

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

Reproduce

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