\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\frac{\frac{c}{\sqrt{c \cdot c + d \cdot d}} \cdot b - a \cdot \frac{d}{\sqrt{c \cdot c + d \cdot d}}}{\sqrt{c \cdot c + d \cdot d}}double f(double a, double b, double c, double d) {
double r5367841 = b;
double r5367842 = c;
double r5367843 = r5367841 * r5367842;
double r5367844 = a;
double r5367845 = d;
double r5367846 = r5367844 * r5367845;
double r5367847 = r5367843 - r5367846;
double r5367848 = r5367842 * r5367842;
double r5367849 = r5367845 * r5367845;
double r5367850 = r5367848 + r5367849;
double r5367851 = r5367847 / r5367850;
return r5367851;
}
double f(double a, double b, double c, double d) {
double r5367852 = c;
double r5367853 = r5367852 * r5367852;
double r5367854 = d;
double r5367855 = r5367854 * r5367854;
double r5367856 = r5367853 + r5367855;
double r5367857 = sqrt(r5367856);
double r5367858 = r5367852 / r5367857;
double r5367859 = b;
double r5367860 = r5367858 * r5367859;
double r5367861 = a;
double r5367862 = r5367854 / r5367857;
double r5367863 = r5367861 * r5367862;
double r5367864 = r5367860 - r5367863;
double r5367865 = r5367864 / r5367857;
return r5367865;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 25.7 |
|---|---|
| Target | 0.6 |
| Herbie | 22.4 |
Initial program 25.7
rmApplied add-sqr-sqrt25.7
Applied associate-/r*25.7
rmApplied div-sub25.7
rmApplied *-un-lft-identity25.7
Applied sqrt-prod25.7
Applied times-frac24.0
Simplified24.0
rmApplied *-un-lft-identity24.0
Applied sqrt-prod24.0
Applied times-frac22.4
Simplified22.4
Final simplification22.4
herbie shell --seed 2019149
(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))))