\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 r32162 = b;
double r32163 = c;
double r32164 = r32162 * r32163;
double r32165 = a;
double r32166 = d;
double r32167 = r32165 * r32166;
double r32168 = r32164 - r32167;
double r32169 = r32163 * r32163;
double r32170 = r32166 * r32166;
double r32171 = r32169 + r32170;
double r32172 = r32168 / r32171;
return r32172;
}
double f(double a, double b, double c, double d) {
double r32173 = 1.0;
double r32174 = c;
double r32175 = r32174 * r32174;
double r32176 = d;
double r32177 = r32176 * r32176;
double r32178 = r32175 + r32177;
double r32179 = sqrt(r32178);
double r32180 = b;
double r32181 = r32180 * r32174;
double r32182 = a;
double r32183 = r32182 * r32176;
double r32184 = r32181 - r32183;
double r32185 = r32179 / r32184;
double r32186 = r32173 / r32185;
double r32187 = r32186 / r32179;
return r32187;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.0 |
|---|---|
| Target | 0.5 |
| Herbie | 25.9 |
Initial program 26.0
rmApplied add-sqr-sqrt26.0
Applied associate-/r*25.9
rmApplied clear-num25.9
Final simplification25.9
herbie shell --seed 2020045
(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))))