\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\frac{\frac{1}{\sqrt{c \cdot c + d \cdot d}} \cdot \left(b \cdot c - a \cdot d\right)}{\sqrt{c \cdot c + d \cdot d}}double f(double a, double b, double c, double d) {
double r5296808 = b;
double r5296809 = c;
double r5296810 = r5296808 * r5296809;
double r5296811 = a;
double r5296812 = d;
double r5296813 = r5296811 * r5296812;
double r5296814 = r5296810 - r5296813;
double r5296815 = r5296809 * r5296809;
double r5296816 = r5296812 * r5296812;
double r5296817 = r5296815 + r5296816;
double r5296818 = r5296814 / r5296817;
return r5296818;
}
double f(double a, double b, double c, double d) {
double r5296819 = 1.0;
double r5296820 = c;
double r5296821 = r5296820 * r5296820;
double r5296822 = d;
double r5296823 = r5296822 * r5296822;
double r5296824 = r5296821 + r5296823;
double r5296825 = sqrt(r5296824);
double r5296826 = r5296819 / r5296825;
double r5296827 = b;
double r5296828 = r5296827 * r5296820;
double r5296829 = a;
double r5296830 = r5296829 * r5296822;
double r5296831 = r5296828 - r5296830;
double r5296832 = r5296826 * r5296831;
double r5296833 = r5296832 / r5296825;
return r5296833;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 25.1 |
|---|---|
| Target | 0.5 |
| Herbie | 25.1 |
Initial program 25.1
rmApplied add-sqr-sqrt25.1
Applied associate-/r*25.0
rmApplied div-inv25.1
Final simplification25.1
herbie shell --seed 2019164
(FPCore (a b c d)
:name "Complex division, imag part"
: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))))