\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\frac{\frac{1}{\frac{\sqrt{\mathsf{fma}\left(d, d, c \cdot c\right)}}{b \cdot c - a \cdot d}}}{\sqrt{\mathsf{fma}\left(d, d, c \cdot c\right)}}double f(double a, double b, double c, double d) {
double r3586751 = b;
double r3586752 = c;
double r3586753 = r3586751 * r3586752;
double r3586754 = a;
double r3586755 = d;
double r3586756 = r3586754 * r3586755;
double r3586757 = r3586753 - r3586756;
double r3586758 = r3586752 * r3586752;
double r3586759 = r3586755 * r3586755;
double r3586760 = r3586758 + r3586759;
double r3586761 = r3586757 / r3586760;
return r3586761;
}
double f(double a, double b, double c, double d) {
double r3586762 = 1.0;
double r3586763 = d;
double r3586764 = c;
double r3586765 = r3586764 * r3586764;
double r3586766 = fma(r3586763, r3586763, r3586765);
double r3586767 = sqrt(r3586766);
double r3586768 = b;
double r3586769 = r3586768 * r3586764;
double r3586770 = a;
double r3586771 = r3586770 * r3586763;
double r3586772 = r3586769 - r3586771;
double r3586773 = r3586767 / r3586772;
double r3586774 = r3586762 / r3586773;
double r3586775 = r3586774 / r3586767;
return r3586775;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
| Original | 25.5 |
|---|---|
| Target | 0.4 |
| Herbie | 25.5 |
Initial program 25.5
Simplified25.5
rmApplied add-sqr-sqrt25.5
Applied associate-/r*25.4
rmApplied *-un-lft-identity25.4
Applied associate-/l*25.5
Final simplification25.5
herbie shell --seed 2019141 +o rules:numerics
(FPCore (a b c d)
:name "Complex division, imag part"
: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))))