\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\frac{\frac{b}{\frac{\sqrt{d \cdot d + c \cdot c}}{c}} - \frac{d}{\sqrt{d \cdot d + c \cdot c}} \cdot a}{\sqrt{c \cdot c + d \cdot d}}double f(double a, double b, double c, double d) {
double r110754 = b;
double r110755 = c;
double r110756 = r110754 * r110755;
double r110757 = a;
double r110758 = d;
double r110759 = r110757 * r110758;
double r110760 = r110756 - r110759;
double r110761 = r110755 * r110755;
double r110762 = r110758 * r110758;
double r110763 = r110761 + r110762;
double r110764 = r110760 / r110763;
return r110764;
}
double f(double a, double b, double c, double d) {
double r110765 = b;
double r110766 = d;
double r110767 = r110766 * r110766;
double r110768 = c;
double r110769 = r110768 * r110768;
double r110770 = r110767 + r110769;
double r110771 = sqrt(r110770);
double r110772 = r110771 / r110768;
double r110773 = r110765 / r110772;
double r110774 = r110766 / r110771;
double r110775 = a;
double r110776 = r110774 * r110775;
double r110777 = r110773 - r110776;
double r110778 = r110769 + r110767;
double r110779 = sqrt(r110778);
double r110780 = r110777 / r110779;
return r110780;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.6 |
|---|---|
| Target | 0.5 |
| Herbie | 22.7 |
Initial program 26.6
rmApplied add-sqr-sqrt26.6
Applied associate-/r*26.5
rmApplied div-sub26.5
Simplified26.5
Simplified25.1
rmApplied associate-/l*23.1
rmApplied associate-/r/22.7
Final simplification22.7
herbie shell --seed 2019347
(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))))