\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 r1518978 = a;
double r1518979 = b;
double r1518980 = c;
double r1518981 = d;
double r1518982 = r1518980 + r1518981;
double r1518983 = r1518979 + r1518982;
double r1518984 = r1518978 + r1518983;
double r1518985 = 2.0;
double r1518986 = r1518984 * r1518985;
return r1518986;
}
double f(double a, double b, double c, double d) {
double r1518987 = 2.0;
double r1518988 = b;
double r1518989 = c;
double r1518990 = r1518988 + r1518989;
double r1518991 = d;
double r1518992 = a;
double r1518993 = r1518991 + r1518992;
double r1518994 = r1518990 + r1518993;
double r1518995 = r1518987 * r1518994;
return r1518995;
}




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 sum-log3.0
Simplified0.9
rmApplied rem-log-exp0
Final simplification0
herbie shell --seed 2019153 +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))