\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\frac{-a \cdot d}{c \cdot c + d \cdot d} + \frac{b \cdot c}{c \cdot c + d \cdot d}double f(double a, double b, double c, double d) {
double r80749 = b;
double r80750 = c;
double r80751 = r80749 * r80750;
double r80752 = a;
double r80753 = d;
double r80754 = r80752 * r80753;
double r80755 = r80751 - r80754;
double r80756 = r80750 * r80750;
double r80757 = r80753 * r80753;
double r80758 = r80756 + r80757;
double r80759 = r80755 / r80758;
return r80759;
}
double f(double a, double b, double c, double d) {
double r80760 = a;
double r80761 = d;
double r80762 = r80760 * r80761;
double r80763 = -r80762;
double r80764 = c;
double r80765 = r80764 * r80764;
double r80766 = r80761 * r80761;
double r80767 = r80765 + r80766;
double r80768 = r80763 / r80767;
double r80769 = b;
double r80770 = r80769 * r80764;
double r80771 = r80770 / r80767;
double r80772 = r80768 + r80771;
return r80772;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 25.8 |
|---|---|
| Target | 0.4 |
| Herbie | 25.8 |
Initial program 25.8
rmApplied add-sqr-sqrt25.8
Applied associate-/r*25.7
rmApplied div-sub25.7
rmApplied add-sqr-sqrt25.7
Applied sqrt-prod25.8
Applied times-frac24.1
rmApplied add-sqr-sqrt24.1
Applied sqrt-prod24.3
Final simplification25.8
herbie shell --seed 2019303
(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))))