\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\frac{b \cdot \frac{c}{\sqrt{c \cdot c + d \cdot d}} - a \cdot \frac{d}{\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 r123603 = b;
double r123604 = c;
double r123605 = r123603 * r123604;
double r123606 = a;
double r123607 = d;
double r123608 = r123606 * r123607;
double r123609 = r123605 - r123608;
double r123610 = r123604 * r123604;
double r123611 = r123607 * r123607;
double r123612 = r123610 + r123611;
double r123613 = r123609 / r123612;
return r123613;
}
double f(double a, double b, double c, double d) {
double r123614 = b;
double r123615 = c;
double r123616 = r123615 * r123615;
double r123617 = d;
double r123618 = r123617 * r123617;
double r123619 = r123616 + r123618;
double r123620 = sqrt(r123619);
double r123621 = r123615 / r123620;
double r123622 = r123614 * r123621;
double r123623 = a;
double r123624 = r123617 / r123620;
double r123625 = r123623 * r123624;
double r123626 = r123622 - r123625;
double r123627 = r123626 / r123620;
return r123627;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.2 |
|---|---|
| Target | 0.5 |
| Herbie | 22.2 |
Initial program 26.2
rmApplied add-sqr-sqrt26.3
Applied associate-/r*26.2
rmApplied div-sub26.2
rmApplied *-un-lft-identity26.2
Applied sqrt-prod26.2
Applied times-frac24.3
Simplified24.3
rmApplied *-un-lft-identity24.3
Applied sqrt-prod24.3
Applied times-frac22.2
Simplified22.2
Final simplification22.2
herbie shell --seed 2020033
(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))))