Average Error: 3.7 → 0.1
Time: 2.3s
Precision: 64
\[-14 \le a \le -13 \land -3 \le b \le -2 \land 3 \le c \le 3.5 \land 12.5 \le d \le 13.5\]
\[\left(a + \left(b + \left(c + d\right)\right)\right) \cdot 2\]
\[\mathsf{log1p}\left(\mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{expm1}\left(\left(d + a\right) + \left(b + c\right)\right)\right)\right)\right) \cdot 2\]
\left(a + \left(b + \left(c + d\right)\right)\right) \cdot 2
\mathsf{log1p}\left(\mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{expm1}\left(\left(d + a\right) + \left(b + c\right)\right)\right)\right)\right) \cdot 2
double f(double a, double b, double c, double d) {
        double r102723 = a;
        double r102724 = b;
        double r102725 = c;
        double r102726 = d;
        double r102727 = r102725 + r102726;
        double r102728 = r102724 + r102727;
        double r102729 = r102723 + r102728;
        double r102730 = 2.0;
        double r102731 = r102729 * r102730;
        return r102731;
}

double f(double a, double b, double c, double d) {
        double r102732 = d;
        double r102733 = a;
        double r102734 = r102732 + r102733;
        double r102735 = b;
        double r102736 = c;
        double r102737 = r102735 + r102736;
        double r102738 = r102734 + r102737;
        double r102739 = expm1(r102738);
        double r102740 = log1p(r102739);
        double r102741 = expm1(r102740);
        double r102742 = log1p(r102741);
        double r102743 = 2.0;
        double r102744 = r102742 * r102743;
        return r102744;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Bits error versus d

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original3.7
Target3.8
Herbie0.1
\[\left(a + b\right) \cdot 2 + \left(c + d\right) \cdot 2\]

Derivation

  1. Initial program 3.7

    \[\left(a + \left(b + \left(c + d\right)\right)\right) \cdot 2\]
  2. Using strategy rm
  3. Applied associate-+r+2.8

    \[\leadsto \left(a + \color{blue}{\left(\left(b + c\right) + d\right)}\right) \cdot 2\]
  4. Using strategy rm
  5. Applied log1p-expm1-u2.8

    \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(a + \left(\left(b + c\right) + d\right)\right)\right)} \cdot 2\]
  6. Using strategy rm
  7. Applied log1p-expm1-u2.8

    \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(a + \left(\left(b + c\right) + d\right)\right)\right)}\right)\right) \cdot 2\]
  8. Simplified2.8

    \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\mathsf{log1p}\left(\color{blue}{\mathsf{expm1}\left(d + \left(a + \left(b + c\right)\right)\right)}\right)\right)\right) \cdot 2\]
  9. Using strategy rm
  10. Applied associate-+r+0.1

    \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{\left(d + a\right) + \left(b + c\right)}\right)\right)\right)\right) \cdot 2\]
  11. Final simplification0.1

    \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{expm1}\left(\left(d + a\right) + \left(b + c\right)\right)\right)\right)\right) \cdot 2\]

Reproduce

herbie shell --seed 2020002 +o rules:numerics
(FPCore (a b c d)
  :name "Expression, p6"
  :precision binary64
  :pre (and (<= -14 a -13) (<= -3 b -2) (<= 3 c 3.5) (<= 12.5 d 13.5))

  :herbie-target
  (+ (* (+ a b) 2) (* (+ c d) 2))

  (* (+ a (+ b (+ c d))) 2))