\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 r87287 = b;
double r87288 = c;
double r87289 = r87287 * r87288;
double r87290 = a;
double r87291 = d;
double r87292 = r87290 * r87291;
double r87293 = r87289 - r87292;
double r87294 = r87288 * r87288;
double r87295 = r87291 * r87291;
double r87296 = r87294 + r87295;
double r87297 = r87293 / r87296;
return r87297;
}
double f(double a, double b, double c, double d) {
double r87298 = 1.0;
double r87299 = c;
double r87300 = r87299 * r87299;
double r87301 = d;
double r87302 = r87301 * r87301;
double r87303 = r87300 + r87302;
double r87304 = sqrt(r87303);
double r87305 = b;
double r87306 = r87305 * r87299;
double r87307 = a;
double r87308 = r87307 * r87301;
double r87309 = r87306 - r87308;
double r87310 = r87304 / r87309;
double r87311 = r87298 / r87310;
double r87312 = r87311 / r87304;
return r87312;
}




Bits error versus a




Bits error versus b




Bits error versus c




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