\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 r77811 = b;
double r77812 = c;
double r77813 = r77811 * r77812;
double r77814 = a;
double r77815 = d;
double r77816 = r77814 * r77815;
double r77817 = r77813 - r77816;
double r77818 = r77812 * r77812;
double r77819 = r77815 * r77815;
double r77820 = r77818 + r77819;
double r77821 = r77817 / r77820;
return r77821;
}
double f(double a, double b, double c, double d) {
double r77822 = 1.0;
double r77823 = c;
double r77824 = r77823 * r77823;
double r77825 = d;
double r77826 = r77825 * r77825;
double r77827 = r77824 + r77826;
double r77828 = sqrt(r77827);
double r77829 = b;
double r77830 = r77829 * r77823;
double r77831 = a;
double r77832 = r77831 * r77825;
double r77833 = r77830 - r77832;
double r77834 = r77828 / r77833;
double r77835 = r77822 / r77834;
double r77836 = r77835 / r77828;
return r77836;
}




Bits error versus a




Bits error versus b




Bits error versus c




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