\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 r3356112 = a;
double r3356113 = b;
double r3356114 = c;
double r3356115 = d;
double r3356116 = r3356114 + r3356115;
double r3356117 = r3356113 + r3356116;
double r3356118 = r3356112 + r3356117;
double r3356119 = 2.0;
double r3356120 = r3356118 * r3356119;
return r3356120;
}
double f(double a, double b, double c, double d) {
double r3356121 = 2.0;
double r3356122 = b;
double r3356123 = c;
double r3356124 = r3356122 + r3356123;
double r3356125 = d;
double r3356126 = a;
double r3356127 = r3356125 + r3356126;
double r3356128 = r3356124 + r3356127;
double r3356129 = r3356121 * r3356128;
return r3356129;
}




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.8
rmApplied add-log-exp2.8
Applied add-log-exp2.8
Applied sum-log2.8
Applied add-log-exp2.8
Applied sum-log1.4
Simplified0.9
rmApplied exp-sum1.2
Applied log-prod0.8
Simplified0.5
Simplified0
Final simplification0
herbie shell --seed 2019151 +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))