\left(a + \left(b + \left(c + d\right)\right)\right) \cdot 2
2 \cdot \left(\left(\left(b + c\right) + d\right) + a\right)
double f(double a, double b, double c, double d) {
double r4055134 = a;
double r4055135 = b;
double r4055136 = c;
double r4055137 = d;
double r4055138 = r4055136 + r4055137;
double r4055139 = r4055135 + r4055138;
double r4055140 = r4055134 + r4055139;
double r4055141 = 2.0;
double r4055142 = r4055140 * r4055141;
return r4055142;
}
double f(double a, double b, double c, double d) {
double r4055143 = 2.0;
double r4055144 = b;
double r4055145 = c;
double r4055146 = r4055144 + r4055145;
double r4055147 = d;
double r4055148 = r4055146 + r4055147;
double r4055149 = a;
double r4055150 = r4055148 + r4055149;
double r4055151 = r4055143 * r4055150;
return r4055151;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 3.6 |
|---|---|
| Target | 3.8 |
| Herbie | 2.8 |
Initial program 3.6
rmApplied associate-+r+2.8
rmApplied log1p-expm1-u2.8
rmApplied log1p-expm12.8
Final simplification2.8
herbie shell --seed 2019134 +o rules:numerics
(FPCore (a b c d)
:name "Expression, p6"
: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))