\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 r5460345 = a;
double r5460346 = b;
double r5460347 = c;
double r5460348 = d;
double r5460349 = r5460347 + r5460348;
double r5460350 = r5460346 + r5460349;
double r5460351 = r5460345 + r5460350;
double r5460352 = 2.0;
double r5460353 = r5460351 * r5460352;
return r5460353;
}
double f(double a, double b, double c, double d) {
double r5460354 = 2.0;
double r5460355 = b;
double r5460356 = c;
double r5460357 = r5460355 + r5460356;
double r5460358 = d;
double r5460359 = a;
double r5460360 = r5460358 + r5460359;
double r5460361 = r5460357 + r5460360;
double r5460362 = r5460354 * r5460361;
return r5460362;
}




Bits error versus a




Bits error versus b




Bits error versus c




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