\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 r105230 = b;
double r105231 = c;
double r105232 = r105230 * r105231;
double r105233 = a;
double r105234 = d;
double r105235 = r105233 * r105234;
double r105236 = r105232 - r105235;
double r105237 = r105231 * r105231;
double r105238 = r105234 * r105234;
double r105239 = r105237 + r105238;
double r105240 = r105236 / r105239;
return r105240;
}
double f(double a, double b, double c, double d) {
double r105241 = 1.0;
double r105242 = c;
double r105243 = r105242 * r105242;
double r105244 = d;
double r105245 = r105244 * r105244;
double r105246 = r105243 + r105245;
double r105247 = sqrt(r105246);
double r105248 = b;
double r105249 = r105248 * r105242;
double r105250 = a;
double r105251 = r105250 * r105244;
double r105252 = r105249 - r105251;
double r105253 = r105247 / r105252;
double r105254 = r105241 / r105253;
double r105255 = r105254 / r105247;
return r105255;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.4 |
|---|---|
| Target | 0.5 |
| Herbie | 26.4 |
Initial program 26.4
rmApplied add-sqr-sqrt26.4
Applied associate-/r*26.3
rmApplied clear-num26.4
Final simplification26.4
herbie shell --seed 2019322
(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))))