\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\frac{\frac{1}{\frac{\sqrt{c \cdot c + d \cdot d}}{b \cdot c - d \cdot a}}}{\sqrt{c \cdot c + d \cdot d}}double f(double a, double b, double c, double d) {
double r113617 = b;
double r113618 = c;
double r113619 = r113617 * r113618;
double r113620 = a;
double r113621 = d;
double r113622 = r113620 * r113621;
double r113623 = r113619 - r113622;
double r113624 = r113618 * r113618;
double r113625 = r113621 * r113621;
double r113626 = r113624 + r113625;
double r113627 = r113623 / r113626;
return r113627;
}
double f(double a, double b, double c, double d) {
double r113628 = 1.0;
double r113629 = c;
double r113630 = r113629 * r113629;
double r113631 = d;
double r113632 = r113631 * r113631;
double r113633 = r113630 + r113632;
double r113634 = sqrt(r113633);
double r113635 = b;
double r113636 = r113635 * r113629;
double r113637 = a;
double r113638 = r113631 * r113637;
double r113639 = r113636 - r113638;
double r113640 = r113634 / r113639;
double r113641 = r113628 / r113640;
double r113642 = r113641 / r113634;
return r113642;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 25.4 |
|---|---|
| Target | 0.5 |
| Herbie | 25.4 |
Initial program 25.4
rmApplied add-sqr-sqrt25.4
Applied associate-/r*25.3
rmApplied clear-num25.4
Simplified25.4
Final simplification25.4
herbie shell --seed 2019212
(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))))