\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 r25184321 = b;
double r25184322 = c;
double r25184323 = r25184321 * r25184322;
double r25184324 = a;
double r25184325 = d;
double r25184326 = r25184324 * r25184325;
double r25184327 = r25184323 - r25184326;
double r25184328 = r25184322 * r25184322;
double r25184329 = r25184325 * r25184325;
double r25184330 = r25184328 + r25184329;
double r25184331 = r25184327 / r25184330;
return r25184331;
}
double f(double a, double b, double c, double d) {
double r25184332 = 1.0;
double r25184333 = c;
double r25184334 = r25184333 * r25184333;
double r25184335 = d;
double r25184336 = r25184335 * r25184335;
double r25184337 = r25184334 + r25184336;
double r25184338 = sqrt(r25184337);
double r25184339 = b;
double r25184340 = r25184333 * r25184339;
double r25184341 = a;
double r25184342 = r25184335 * r25184341;
double r25184343 = r25184340 - r25184342;
double r25184344 = r25184338 / r25184343;
double r25184345 = r25184332 / r25184344;
double r25184346 = r25184345 / r25184338;
return r25184346;
}




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.5
rmApplied *-un-lft-identity25.5
Applied associate-/l*25.5
Final simplification25.5
herbie shell --seed 2019119
(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))))