\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\frac{\left(b \cdot c - a \cdot d\right) \cdot \frac{1}{\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 r70321 = b;
double r70322 = c;
double r70323 = r70321 * r70322;
double r70324 = a;
double r70325 = d;
double r70326 = r70324 * r70325;
double r70327 = r70323 - r70326;
double r70328 = r70322 * r70322;
double r70329 = r70325 * r70325;
double r70330 = r70328 + r70329;
double r70331 = r70327 / r70330;
return r70331;
}
double f(double a, double b, double c, double d) {
double r70332 = b;
double r70333 = c;
double r70334 = r70332 * r70333;
double r70335 = a;
double r70336 = d;
double r70337 = r70335 * r70336;
double r70338 = r70334 - r70337;
double r70339 = 1.0;
double r70340 = r70333 * r70333;
double r70341 = r70336 * r70336;
double r70342 = r70340 + r70341;
double r70343 = sqrt(r70342);
double r70344 = r70339 / r70343;
double r70345 = r70338 * r70344;
double r70346 = r70345 / r70343;
return r70346;
}




Bits error versus a




Bits error versus b




Bits error versus c




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