\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 r4373356 = a;
double r4373357 = b;
double r4373358 = c;
double r4373359 = d;
double r4373360 = r4373358 + r4373359;
double r4373361 = r4373357 + r4373360;
double r4373362 = r4373356 + r4373361;
double r4373363 = 2.0;
double r4373364 = r4373362 * r4373363;
return r4373364;
}
double f(double a, double b, double c, double d) {
double r4373365 = 2.0;
double r4373366 = b;
double r4373367 = c;
double r4373368 = r4373366 + r4373367;
double r4373369 = d;
double r4373370 = a;
double r4373371 = r4373369 + r4373370;
double r4373372 = r4373368 + r4373371;
double r4373373 = r4373365 * r4373372;
return r4373373;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 3.7 |
|---|---|
| Target | 3.9 |
| Herbie | 0 |
Initial program 3.7
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 2019169 +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))