\left(a + \left(b + \left(c + d\right)\right)\right) \cdot 2
2 \cdot \left(\left(b + c\right) + \left(d + a\right)\right)
double f(double a, double b, double c, double d) {
double r2778228 = a;
double r2778229 = b;
double r2778230 = c;
double r2778231 = d;
double r2778232 = r2778230 + r2778231;
double r2778233 = r2778229 + r2778232;
double r2778234 = r2778228 + r2778233;
double r2778235 = 2.0;
double r2778236 = r2778234 * r2778235;
return r2778236;
}
double f(double a, double b, double c, double d) {
double r2778237 = 2.0;
double r2778238 = b;
double r2778239 = c;
double r2778240 = r2778238 + r2778239;
double r2778241 = d;
double r2778242 = a;
double r2778243 = r2778241 + r2778242;
double r2778244 = r2778240 + r2778243;
double r2778245 = r2778237 * r2778244;
return r2778245;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 3.6 |
|---|---|
| Target | 3.8 |
| Herbie | 0 |
Initial program 3.6
rmApplied associate-+r+2.8
rmApplied add-log-exp2.8
Applied add-log-exp2.8
Applied add-log-exp2.8
Applied sum-log2.8
Applied sum-log2.8
Applied add-log-exp2.8
Applied sum-log1.5
Simplified0.9
rmApplied rem-log-exp0
Final simplification0
herbie shell --seed 2019192 +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))