\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 r9079917 = a;
double r9079918 = c;
double r9079919 = r9079917 * r9079918;
double r9079920 = b;
double r9079921 = d;
double r9079922 = r9079920 * r9079921;
double r9079923 = r9079919 + r9079922;
double r9079924 = r9079918 * r9079918;
double r9079925 = r9079921 * r9079921;
double r9079926 = r9079924 + r9079925;
double r9079927 = r9079923 / r9079926;
return r9079927;
}
double f(double a, double b, double c, double d) {
double r9079928 = 1.0;
double r9079929 = c;
double r9079930 = r9079929 * r9079929;
double r9079931 = d;
double r9079932 = r9079931 * r9079931;
double r9079933 = r9079930 + r9079932;
double r9079934 = sqrt(r9079933);
double r9079935 = r9079928 / r9079934;
double r9079936 = b;
double r9079937 = r9079936 * r9079931;
double r9079938 = a;
double r9079939 = r9079938 * r9079929;
double r9079940 = r9079937 + r9079939;
double r9079941 = r9079935 * r9079940;
double r9079942 = r9079941 / r9079934;
return r9079942;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.2 |
|---|---|
| Target | 0.5 |
| Herbie | 26.2 |
Initial program 26.2
rmApplied add-sqr-sqrt26.2
Applied associate-/r*26.1
rmApplied div-inv26.2
Final simplification26.2
herbie shell --seed 2019121
(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))))