\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\frac{\frac{1}{\frac{1}{c \cdot a + b \cdot d}}}{d \cdot d + c \cdot c}double f(double a, double b, double c, double d) {
double r21916280 = a;
double r21916281 = c;
double r21916282 = r21916280 * r21916281;
double r21916283 = b;
double r21916284 = d;
double r21916285 = r21916283 * r21916284;
double r21916286 = r21916282 + r21916285;
double r21916287 = r21916281 * r21916281;
double r21916288 = r21916284 * r21916284;
double r21916289 = r21916287 + r21916288;
double r21916290 = r21916286 / r21916289;
return r21916290;
}
double f(double a, double b, double c, double d) {
double r21916291 = 1.0;
double r21916292 = c;
double r21916293 = a;
double r21916294 = r21916292 * r21916293;
double r21916295 = b;
double r21916296 = d;
double r21916297 = r21916295 * r21916296;
double r21916298 = r21916294 + r21916297;
double r21916299 = r21916291 / r21916298;
double r21916300 = r21916291 / r21916299;
double r21916301 = r21916296 * r21916296;
double r21916302 = r21916292 * r21916292;
double r21916303 = r21916301 + r21916302;
double r21916304 = r21916300 / r21916303;
return r21916304;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 25.3 |
|---|---|
| Target | 0.5 |
| Herbie | 25.4 |
Initial program 25.3
rmApplied add-sqr-sqrt25.3
Applied associate-/r*25.2
rmApplied *-un-lft-identity25.2
Applied *-un-lft-identity25.2
Applied times-frac25.2
Applied associate-/l*25.4
Simplified25.4
rmApplied div-inv25.4
Applied *-un-lft-identity25.4
Applied times-frac25.6
Applied associate-/r*25.4
Simplified25.4
Final simplification25.4
herbie shell --seed 2019119
(FPCore (a b c d)
:name "Complex division, real part"
:herbie-target
(if (< (fabs d) (fabs c)) (/ (+ a (* b (/ d c))) (+ c (* d (/ d c)))) (/ (+ b (* a (/ c d))) (+ d (* c (/ c d)))))
(/ (+ (* a c) (* b d)) (+ (* c c) (* d d))))