\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\frac{\frac{b \cdot c - a \cdot d}{\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 r25570490 = b;
double r25570491 = c;
double r25570492 = r25570490 * r25570491;
double r25570493 = a;
double r25570494 = d;
double r25570495 = r25570493 * r25570494;
double r25570496 = r25570492 - r25570495;
double r25570497 = r25570491 * r25570491;
double r25570498 = r25570494 * r25570494;
double r25570499 = r25570497 + r25570498;
double r25570500 = r25570496 / r25570499;
return r25570500;
}
double f(double a, double b, double c, double d) {
double r25570501 = b;
double r25570502 = c;
double r25570503 = r25570501 * r25570502;
double r25570504 = a;
double r25570505 = d;
double r25570506 = r25570504 * r25570505;
double r25570507 = r25570503 - r25570506;
double r25570508 = r25570502 * r25570502;
double r25570509 = r25570505 * r25570505;
double r25570510 = r25570508 + r25570509;
double r25570511 = sqrt(r25570510);
double r25570512 = r25570507 / r25570511;
double r25570513 = r25570512 / r25570511;
return r25570513;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 25.6 |
|---|---|
| Target | 0.6 |
| Herbie | 25.5 |
Initial program 25.6
rmApplied add-sqr-sqrt25.6
Applied associate-/r*25.5
rmApplied *-un-lft-identity25.5
Applied associate-/r*25.5
Final simplification25.5
herbie shell --seed 2019107
(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))))