\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}double f(double a, double b, double c, double d) {
double r67879 = a;
double r67880 = c;
double r67881 = r67879 * r67880;
double r67882 = b;
double r67883 = d;
double r67884 = r67882 * r67883;
double r67885 = r67881 + r67884;
double r67886 = r67880 * r67880;
double r67887 = r67883 * r67883;
double r67888 = r67886 + r67887;
double r67889 = r67885 / r67888;
return r67889;
}
double f(double a, double b, double c, double d) {
double r67890 = a;
double r67891 = c;
double r67892 = r67890 * r67891;
double r67893 = b;
double r67894 = d;
double r67895 = r67893 * r67894;
double r67896 = r67892 + r67895;
double r67897 = r67891 * r67891;
double r67898 = r67894 * r67894;
double r67899 = r67897 + r67898;
double r67900 = r67896 / r67899;
return r67900;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.0 |
|---|---|
| Target | 0.5 |
| Herbie | 26.0 |
Initial program 26.0
rmApplied add-sqr-sqrt26.0
Applied associate-/r*26.0
Final simplification26.0
herbie shell --seed 2019298
(FPCore (a b c d)
:name "Complex division, real part"
:precision binary64
: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))))