Average Error: 0.7 → 0.7
Time: 33.4s
Precision: 64
\[\frac{e^{a}}{e^{a} + e^{b}}\]
\[\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{e^{a}}{e^{b} + e^{a}}\right)\right)\]
\frac{e^{a}}{e^{a} + e^{b}}
\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{e^{a}}{e^{b} + e^{a}}\right)\right)
double f(double a, double b) {
        double r4865255 = a;
        double r4865256 = exp(r4865255);
        double r4865257 = b;
        double r4865258 = exp(r4865257);
        double r4865259 = r4865256 + r4865258;
        double r4865260 = r4865256 / r4865259;
        return r4865260;
}

double f(double a, double b) {
        double r4865261 = a;
        double r4865262 = exp(r4865261);
        double r4865263 = b;
        double r4865264 = exp(r4865263);
        double r4865265 = r4865264 + r4865262;
        double r4865266 = r4865262 / r4865265;
        double r4865267 = expm1(r4865266);
        double r4865268 = log1p(r4865267);
        return r4865268;
}

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.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. Using strategy rm
  3. Applied log1p-expm1-u0.7

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

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

Reproduce

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

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

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