\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\frac{\left(b \cdot c - a \cdot d\right) \cdot \frac{1}{\sqrt{c \cdot c + d \cdot d}}}{\sqrt{c \cdot c + d \cdot d}}double f(double a, double b, double c, double d) {
double r88758 = b;
double r88759 = c;
double r88760 = r88758 * r88759;
double r88761 = a;
double r88762 = d;
double r88763 = r88761 * r88762;
double r88764 = r88760 - r88763;
double r88765 = r88759 * r88759;
double r88766 = r88762 * r88762;
double r88767 = r88765 + r88766;
double r88768 = r88764 / r88767;
return r88768;
}
double f(double a, double b, double c, double d) {
double r88769 = b;
double r88770 = c;
double r88771 = r88769 * r88770;
double r88772 = a;
double r88773 = d;
double r88774 = r88772 * r88773;
double r88775 = r88771 - r88774;
double r88776 = 1.0;
double r88777 = r88770 * r88770;
double r88778 = r88773 * r88773;
double r88779 = r88777 + r88778;
double r88780 = sqrt(r88779);
double r88781 = r88776 / r88780;
double r88782 = r88775 * r88781;
double r88783 = r88782 / r88780;
return r88783;
}




Bits error versus a




Bits error versus b




Bits error versus c




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