\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\frac{\frac{1}{\sqrt{c \cdot c + d \cdot d}} \cdot \left(b \cdot d + a \cdot c\right)}{\sqrt{c \cdot c + d \cdot d}}double f(double a, double b, double c, double d) {
double r5662059 = a;
double r5662060 = c;
double r5662061 = r5662059 * r5662060;
double r5662062 = b;
double r5662063 = d;
double r5662064 = r5662062 * r5662063;
double r5662065 = r5662061 + r5662064;
double r5662066 = r5662060 * r5662060;
double r5662067 = r5662063 * r5662063;
double r5662068 = r5662066 + r5662067;
double r5662069 = r5662065 / r5662068;
return r5662069;
}
double f(double a, double b, double c, double d) {
double r5662070 = 1.0;
double r5662071 = c;
double r5662072 = r5662071 * r5662071;
double r5662073 = d;
double r5662074 = r5662073 * r5662073;
double r5662075 = r5662072 + r5662074;
double r5662076 = sqrt(r5662075);
double r5662077 = r5662070 / r5662076;
double r5662078 = b;
double r5662079 = r5662078 * r5662073;
double r5662080 = a;
double r5662081 = r5662080 * r5662071;
double r5662082 = r5662079 + r5662081;
double r5662083 = r5662077 * r5662082;
double r5662084 = r5662083 / r5662076;
return r5662084;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 25.8 |
|---|---|
| Target | 0.4 |
| Herbie | 25.8 |
Initial program 25.8
rmApplied add-sqr-sqrt25.8
Applied associate-/r*25.7
rmApplied div-inv25.8
Final simplification25.8
herbie shell --seed 2019163
(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))))