\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 r120349 = b;
double r120350 = c;
double r120351 = r120349 * r120350;
double r120352 = a;
double r120353 = d;
double r120354 = r120352 * r120353;
double r120355 = r120351 - r120354;
double r120356 = r120350 * r120350;
double r120357 = r120353 * r120353;
double r120358 = r120356 + r120357;
double r120359 = r120355 / r120358;
return r120359;
}
double f(double a, double b, double c, double d) {
double r120360 = 1.0;
double r120361 = c;
double r120362 = r120361 * r120361;
double r120363 = d;
double r120364 = r120363 * r120363;
double r120365 = r120362 + r120364;
double r120366 = sqrt(r120365);
double r120367 = b;
double r120368 = r120367 * r120361;
double r120369 = a;
double r120370 = r120369 * r120363;
double r120371 = r120368 - r120370;
double r120372 = r120366 / r120371;
double r120373 = r120360 / r120372;
double r120374 = r120373 / r120366;
return r120374;
}




Bits error versus a




Bits error versus b




Bits error versus c




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