\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}double f(double a, double b, double c, double d) {
double r155925 = b;
double r155926 = c;
double r155927 = r155925 * r155926;
double r155928 = a;
double r155929 = d;
double r155930 = r155928 * r155929;
double r155931 = r155927 - r155930;
double r155932 = r155926 * r155926;
double r155933 = r155929 * r155929;
double r155934 = r155932 + r155933;
double r155935 = r155931 / r155934;
return r155935;
}
double f(double a, double b, double c, double d) {
double r155936 = b;
double r155937 = c;
double r155938 = r155936 * r155937;
double r155939 = a;
double r155940 = d;
double r155941 = r155939 * r155940;
double r155942 = r155938 - r155941;
double r155943 = r155937 * r155937;
double r155944 = r155940 * r155940;
double r155945 = r155943 + r155944;
double r155946 = r155942 / r155945;
return r155946;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 25.9 |
|---|---|
| Target | 0.5 |
| Herbie | 25.9 |
Initial program 25.9
rmApplied add-sqr-sqrt25.9
Applied associate-/r*25.8
rmApplied *-un-lft-identity25.8
Applied sqrt-prod25.8
Applied *-un-lft-identity25.8
Applied sqrt-prod25.8
Applied *-un-lft-identity25.8
Applied times-frac25.8
Applied times-frac25.8
Simplified25.8
Simplified25.9
Final simplification25.9
herbie shell --seed 2020036
(FPCore (a b c d)
:name "Complex division, imag part"
:precision binary64
:herbie-target
(if (< (fabs d) (fabs c)) (/ (- b (* a (/ d c))) (+ c (* d (/ d c)))) (/ (+ (- a) (* b (/ c d))) (+ d (* c (/ c d)))))
(/ (- (* b c) (* a d)) (+ (* c c) (* d d))))