\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 r84005 = b;
double r84006 = c;
double r84007 = r84005 * r84006;
double r84008 = a;
double r84009 = d;
double r84010 = r84008 * r84009;
double r84011 = r84007 - r84010;
double r84012 = r84006 * r84006;
double r84013 = r84009 * r84009;
double r84014 = r84012 + r84013;
double r84015 = r84011 / r84014;
return r84015;
}
double f(double a, double b, double c, double d) {
double r84016 = 1.0;
double r84017 = c;
double r84018 = r84017 * r84017;
double r84019 = d;
double r84020 = r84019 * r84019;
double r84021 = r84018 + r84020;
double r84022 = sqrt(r84021);
double r84023 = b;
double r84024 = r84023 * r84017;
double r84025 = a;
double r84026 = r84025 * r84019;
double r84027 = r84024 - r84026;
double r84028 = r84022 / r84027;
double r84029 = r84016 / r84028;
double r84030 = r84029 / r84022;
return r84030;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.0 |
|---|---|
| Target | 0.5 |
| Herbie | 25.9 |
Initial program 26.0
rmApplied add-sqr-sqrt26.0
Applied associate-/r*25.9
rmApplied clear-num25.9
Final simplification25.9
herbie shell --seed 2020045
(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))))