\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\frac{\frac{1}{\frac{\sqrt{c \cdot c + d \cdot d}}{c \cdot b - d \cdot a}}}{\sqrt{c \cdot c + d \cdot d}}double f(double a, double b, double c, double d) {
double r3674561 = b;
double r3674562 = c;
double r3674563 = r3674561 * r3674562;
double r3674564 = a;
double r3674565 = d;
double r3674566 = r3674564 * r3674565;
double r3674567 = r3674563 - r3674566;
double r3674568 = r3674562 * r3674562;
double r3674569 = r3674565 * r3674565;
double r3674570 = r3674568 + r3674569;
double r3674571 = r3674567 / r3674570;
return r3674571;
}
double f(double a, double b, double c, double d) {
double r3674572 = 1.0;
double r3674573 = c;
double r3674574 = r3674573 * r3674573;
double r3674575 = d;
double r3674576 = r3674575 * r3674575;
double r3674577 = r3674574 + r3674576;
double r3674578 = sqrt(r3674577);
double r3674579 = b;
double r3674580 = r3674573 * r3674579;
double r3674581 = a;
double r3674582 = r3674575 * r3674581;
double r3674583 = r3674580 - r3674582;
double r3674584 = r3674578 / r3674583;
double r3674585 = r3674572 / r3674584;
double r3674586 = r3674585 / r3674578;
return r3674586;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 25.5 |
|---|---|
| Target | 0.4 |
| Herbie | 25.5 |
Initial program 25.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
(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))))