Average Error: 0.8 → 0.0
Time: 20.5s
Precision: 64
\[\frac{e^{a}}{e^{a} + e^{b}}\]
\[e^{-\mathsf{log1p}\left(e^{b - a}\right)}\]
\frac{e^{a}}{e^{a} + e^{b}}
e^{-\mathsf{log1p}\left(e^{b - a}\right)}
double f(double a, double b) {
        double r98221 = a;
        double r98222 = exp(r98221);
        double r98223 = b;
        double r98224 = exp(r98223);
        double r98225 = r98222 + r98224;
        double r98226 = r98222 / r98225;
        return r98226;
}

double f(double a, double b) {
        double r98227 = b;
        double r98228 = a;
        double r98229 = r98227 - r98228;
        double r98230 = exp(r98229);
        double r98231 = log1p(r98230);
        double r98232 = -r98231;
        double r98233 = exp(r98232);
        return r98233;
}

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

Derivation

  1. Initial program 0.8

    \[\frac{e^{a}}{e^{a} + e^{b}}\]
  2. Using strategy rm
  3. Applied clear-num0.8

    \[\leadsto \color{blue}{\frac{1}{\frac{e^{a} + e^{b}}{e^{a}}}}\]
  4. Simplified0.8

    \[\leadsto \frac{1}{\color{blue}{\frac{e^{b} + e^{a}}{e^{a}}}}\]
  5. Using strategy rm
  6. Applied add-exp-log0.8

    \[\leadsto \frac{1}{\frac{\color{blue}{e^{\log \left(e^{b} + e^{a}\right)}}}{e^{a}}}\]
  7. Applied div-exp0.7

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

    \[\leadsto \frac{1}{e^{\color{blue}{\log \left(e^{b - a} + 1\right)}}}\]
  9. Using strategy rm
  10. Applied rec-exp0.0

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

    \[\leadsto e^{\color{blue}{-\mathsf{log1p}\left(e^{b - a}\right)}}\]
  12. Final simplification0.0

    \[\leadsto e^{-\mathsf{log1p}\left(e^{b - a}\right)}\]

Reproduce

herbie shell --seed 2019304 +o rules:numerics
(FPCore (a b)
  :name "Quotient of sum of exps"
  :precision binary64

  :herbie-target
  (/ 1 (+ 1 (exp (- b a))))

  (/ (exp a) (+ (exp a) (exp b))))