\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}}}{\sqrt{c \cdot c + d \cdot d}} - \frac{a \cdot d}{c \cdot c + d \cdot d}double f(double a, double b, double c, double d) {
double r116589 = b;
double r116590 = c;
double r116591 = r116589 * r116590;
double r116592 = a;
double r116593 = d;
double r116594 = r116592 * r116593;
double r116595 = r116591 - r116594;
double r116596 = r116590 * r116590;
double r116597 = r116593 * r116593;
double r116598 = r116596 + r116597;
double r116599 = r116595 / r116598;
return r116599;
}
double f(double a, double b, double c, double d) {
double r116600 = b;
double r116601 = c;
double r116602 = r116601 * r116601;
double r116603 = d;
double r116604 = r116603 * r116603;
double r116605 = r116602 + r116604;
double r116606 = sqrt(r116605);
double r116607 = r116601 / r116606;
double r116608 = r116600 * r116607;
double r116609 = r116608 / r116606;
double r116610 = a;
double r116611 = r116610 * r116603;
double r116612 = r116611 / r116605;
double r116613 = r116609 - r116612;
return r116613;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 25.5 |
|---|---|
| Target | 0.5 |
| Herbie | 23.8 |
Initial program 25.5
rmApplied div-sub25.5
rmApplied add-sqr-sqrt25.5
Applied times-frac24.3
rmApplied associate-*r/24.2
Simplified23.8
Final simplification23.8
herbie shell --seed 2020035
(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))))