Average Error: 0.6 → 0.6
Time: 19.7s
Precision: 64
\[\frac{e^{a}}{e^{a} + e^{b}}\]
\[\mathsf{log1p}\left(\left(\mathsf{expm1}\left(\left(\frac{e^{a}}{e^{a} + e^{b}}\right)\right)\right)\right)\]
\frac{e^{a}}{e^{a} + e^{b}}
\mathsf{log1p}\left(\left(\mathsf{expm1}\left(\left(\frac{e^{a}}{e^{a} + e^{b}}\right)\right)\right)\right)
double f(double a, double b) {
        double r40294068 = a;
        double r40294069 = exp(r40294068);
        double r40294070 = b;
        double r40294071 = exp(r40294070);
        double r40294072 = r40294069 + r40294071;
        double r40294073 = r40294069 / r40294072;
        return r40294073;
}

double f(double a, double b) {
        double r40294074 = a;
        double r40294075 = exp(r40294074);
        double r40294076 = b;
        double r40294077 = exp(r40294076);
        double r40294078 = r40294075 + r40294077;
        double r40294079 = r40294075 / r40294078;
        double r40294080 = expm1(r40294079);
        double r40294081 = log1p(r40294080);
        return r40294081;
}

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 log1p-expm1-u0.6

    \[\leadsto \color{blue}{\mathsf{log1p}\left(\left(\mathsf{expm1}\left(\left(\frac{e^{a}}{e^{a} + e^{b}}\right)\right)\right)\right)}\]
  4. Final simplification0.6

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

Reproduce

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

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

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