\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 r81459 = b;
double r81460 = c;
double r81461 = r81459 * r81460;
double r81462 = a;
double r81463 = d;
double r81464 = r81462 * r81463;
double r81465 = r81461 - r81464;
double r81466 = r81460 * r81460;
double r81467 = r81463 * r81463;
double r81468 = r81466 + r81467;
double r81469 = r81465 / r81468;
return r81469;
}
double f(double a, double b, double c, double d) {
double r81470 = 1.0;
double r81471 = c;
double r81472 = r81471 * r81471;
double r81473 = d;
double r81474 = r81473 * r81473;
double r81475 = r81472 + r81474;
double r81476 = sqrt(r81475);
double r81477 = b;
double r81478 = r81477 * r81471;
double r81479 = a;
double r81480 = r81479 * r81473;
double r81481 = r81478 - r81480;
double r81482 = r81476 / r81481;
double r81483 = r81470 / r81482;
double r81484 = r81483 / r81476;
return r81484;
}




Bits error versus a




Bits error versus b




Bits error versus c




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