\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 r26293365 = b;
double r26293366 = c;
double r26293367 = r26293365 * r26293366;
double r26293368 = a;
double r26293369 = d;
double r26293370 = r26293368 * r26293369;
double r26293371 = r26293367 - r26293370;
double r26293372 = r26293366 * r26293366;
double r26293373 = r26293369 * r26293369;
double r26293374 = r26293372 + r26293373;
double r26293375 = r26293371 / r26293374;
return r26293375;
}
double f(double a, double b, double c, double d) {
double r26293376 = b;
double r26293377 = c;
double r26293378 = r26293376 * r26293377;
double r26293379 = a;
double r26293380 = d;
double r26293381 = r26293379 * r26293380;
double r26293382 = r26293378 - r26293381;
double r26293383 = r26293377 * r26293377;
double r26293384 = r26293380 * r26293380;
double r26293385 = r26293383 + r26293384;
double r26293386 = sqrt(r26293385);
double r26293387 = r26293382 / r26293386;
double r26293388 = r26293387 / r26293386;
return r26293388;
}




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))))