\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 r3677896 = a;
double r3677897 = b;
double r3677898 = c;
double r3677899 = d;
double r3677900 = r3677898 + r3677899;
double r3677901 = r3677897 + r3677900;
double r3677902 = r3677896 + r3677901;
double r3677903 = 2.0;
double r3677904 = r3677902 * r3677903;
return r3677904;
}
double f(double a, double b, double c, double d) {
double r3677905 = 2.0;
double r3677906 = b;
double r3677907 = c;
double r3677908 = r3677906 + r3677907;
double r3677909 = d;
double r3677910 = a;
double r3677911 = r3677909 + r3677910;
double r3677912 = r3677908 + r3677911;
double r3677913 = r3677905 * r3677912;
return r3677913;
}




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 2019164 +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))