\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\frac{\frac{b \cdot c}{\sqrt{c \cdot c + d \cdot d}} - \frac{a}{\frac{\sqrt{c \cdot c + d \cdot d}}{d}}}{\sqrt{c \cdot c + d \cdot d}}double f(double a, double b, double c, double d) {
double r151767 = b;
double r151768 = c;
double r151769 = r151767 * r151768;
double r151770 = a;
double r151771 = d;
double r151772 = r151770 * r151771;
double r151773 = r151769 - r151772;
double r151774 = r151768 * r151768;
double r151775 = r151771 * r151771;
double r151776 = r151774 + r151775;
double r151777 = r151773 / r151776;
return r151777;
}
double f(double a, double b, double c, double d) {
double r151778 = b;
double r151779 = c;
double r151780 = r151778 * r151779;
double r151781 = r151779 * r151779;
double r151782 = d;
double r151783 = r151782 * r151782;
double r151784 = r151781 + r151783;
double r151785 = sqrt(r151784);
double r151786 = r151780 / r151785;
double r151787 = a;
double r151788 = r151785 / r151782;
double r151789 = r151787 / r151788;
double r151790 = r151786 - r151789;
double r151791 = r151790 / r151785;
return r151791;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.1 |
|---|---|
| Target | 0.5 |
| Herbie | 24.5 |
Initial program 26.1
rmApplied add-sqr-sqrt26.1
Applied associate-/r*26.1
rmApplied div-sub26.1
rmApplied associate-/l*24.5
Final simplification24.5
herbie shell --seed 2020062
(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))))