Average Error: 3.7 → 0
Time: 14.6s
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\]
\[2 \cdot \left(\left(c + b\right) + \left(a + d\right)\right)\]
\left(a + \left(b + \left(c + d\right)\right)\right) \cdot 2
2 \cdot \left(\left(c + b\right) + \left(a + d\right)\right)
double f(double a, double b, double c, double d) {
        double r3178630 = a;
        double r3178631 = b;
        double r3178632 = c;
        double r3178633 = d;
        double r3178634 = r3178632 + r3178633;
        double r3178635 = r3178631 + r3178634;
        double r3178636 = r3178630 + r3178635;
        double r3178637 = 2.0;
        double r3178638 = r3178636 * r3178637;
        return r3178638;
}

double f(double a, double b, double c, double d) {
        double r3178639 = 2.0;
        double r3178640 = c;
        double r3178641 = b;
        double r3178642 = r3178640 + r3178641;
        double r3178643 = a;
        double r3178644 = d;
        double r3178645 = r3178643 + r3178644;
        double r3178646 = r3178642 + r3178645;
        double r3178647 = r3178639 * r3178646;
        return r3178647;
}

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
\[\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 add-log-exp3.7

    \[\leadsto \left(a + \left(b + \left(c + \color{blue}{\log \left(e^{d}\right)}\right)\right)\right) \cdot 2\]
  4. Applied add-log-exp3.7

    \[\leadsto \left(a + \left(b + \left(\color{blue}{\log \left(e^{c}\right)} + \log \left(e^{d}\right)\right)\right)\right) \cdot 2\]
  5. Applied sum-log3.7

    \[\leadsto \left(a + \left(b + \color{blue}{\log \left(e^{c} \cdot e^{d}\right)}\right)\right) \cdot 2\]
  6. Applied add-log-exp3.7

    \[\leadsto \left(a + \left(\color{blue}{\log \left(e^{b}\right)} + \log \left(e^{c} \cdot e^{d}\right)\right)\right) \cdot 2\]
  7. Applied sum-log2.8

    \[\leadsto \left(a + \color{blue}{\log \left(e^{b} \cdot \left(e^{c} \cdot e^{d}\right)\right)}\right) \cdot 2\]
  8. Applied add-log-exp2.8

    \[\leadsto \left(\color{blue}{\log \left(e^{a}\right)} + \log \left(e^{b} \cdot \left(e^{c} \cdot e^{d}\right)\right)\right) \cdot 2\]
  9. Applied sum-log1.5

    \[\leadsto \color{blue}{\log \left(e^{a} \cdot \left(e^{b} \cdot \left(e^{c} \cdot e^{d}\right)\right)\right)} \cdot 2\]
  10. Simplified0.9

    \[\leadsto \log \color{blue}{\left(e^{\left(c + b\right) + \left(d + a\right)}\right)} \cdot 2\]
  11. Using strategy rm
  12. Applied exp-sum1.2

    \[\leadsto \log \color{blue}{\left(e^{c + b} \cdot e^{d + a}\right)} \cdot 2\]
  13. Applied log-prod0.8

    \[\leadsto \color{blue}{\left(\log \left(e^{c + b}\right) + \log \left(e^{d + a}\right)\right)} \cdot 2\]
  14. Simplified0.5

    \[\leadsto \left(\color{blue}{\left(c + b\right)} + \log \left(e^{d + a}\right)\right) \cdot 2\]
  15. Simplified0

    \[\leadsto \left(\left(c + b\right) + \color{blue}{\left(d + a\right)}\right) \cdot 2\]
  16. Final simplification0

    \[\leadsto 2 \cdot \left(\left(c + b\right) + \left(a + d\right)\right)\]

Reproduce

herbie shell --seed 2019200 +o rules:numerics
(FPCore (a b c d)
  :name "Expression, p6"
  :pre (and (<= -14.0 a -13.0) (<= -3.0 b -2.0) (<= 3.0 c 3.5) (<= 12.5 d 13.5))

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

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