\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 - a \cdot d}}}{\sqrt{c \cdot c + d \cdot d}}double f(double a, double b, double c, double d) {
double r28611 = b;
double r28612 = c;
double r28613 = r28611 * r28612;
double r28614 = a;
double r28615 = d;
double r28616 = r28614 * r28615;
double r28617 = r28613 - r28616;
double r28618 = r28612 * r28612;
double r28619 = r28615 * r28615;
double r28620 = r28618 + r28619;
double r28621 = r28617 / r28620;
return r28621;
}
double f(double a, double b, double c, double d) {
double r28622 = 1.0;
double r28623 = c;
double r28624 = r28623 * r28623;
double r28625 = d;
double r28626 = r28625 * r28625;
double r28627 = r28624 + r28626;
double r28628 = sqrt(r28627);
double r28629 = b;
double r28630 = r28629 * r28623;
double r28631 = a;
double r28632 = r28631 * r28625;
double r28633 = r28630 - r28632;
double r28634 = r28628 / r28633;
double r28635 = r28622 / r28634;
double r28636 = r28635 / r28628;
return r28636;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.0 |
|---|---|
| Target | 0.5 |
| Herbie | 25.9 |
Initial program 26.0
rmApplied add-sqr-sqrt26.0
Applied associate-/r*25.9
rmApplied clear-num25.9
Final simplification25.9
herbie shell --seed 2020045
(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))))