\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\frac{\frac{b \cdot c}{\sqrt{c \cdot c + d \cdot d}} - \frac{a}{\frac{\sqrt{c \cdot c + d \cdot d}}{d}}}{\sqrt{c \cdot c + d \cdot d}}double f(double a, double b, double c, double d) {
double r147752 = b;
double r147753 = c;
double r147754 = r147752 * r147753;
double r147755 = a;
double r147756 = d;
double r147757 = r147755 * r147756;
double r147758 = r147754 - r147757;
double r147759 = r147753 * r147753;
double r147760 = r147756 * r147756;
double r147761 = r147759 + r147760;
double r147762 = r147758 / r147761;
return r147762;
}
double f(double a, double b, double c, double d) {
double r147763 = b;
double r147764 = c;
double r147765 = r147763 * r147764;
double r147766 = r147764 * r147764;
double r147767 = d;
double r147768 = r147767 * r147767;
double r147769 = r147766 + r147768;
double r147770 = sqrt(r147769);
double r147771 = r147765 / r147770;
double r147772 = a;
double r147773 = r147770 / r147767;
double r147774 = r147772 / r147773;
double r147775 = r147771 - r147774;
double r147776 = r147775 / r147770;
return r147776;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.1 |
|---|---|
| Target | 0.5 |
| Herbie | 24.5 |
Initial program 26.1
rmApplied add-sqr-sqrt26.1
Applied associate-/r*26.1
rmApplied div-sub26.1
rmApplied associate-/l*24.5
Final simplification24.5
herbie shell --seed 2020062
(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))))