\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\frac{\frac{b}{\frac{\sqrt{c \cdot c + d \cdot d}}{c}} - \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 r113203 = b;
double r113204 = c;
double r113205 = r113203 * r113204;
double r113206 = a;
double r113207 = d;
double r113208 = r113206 * r113207;
double r113209 = r113205 - r113208;
double r113210 = r113204 * r113204;
double r113211 = r113207 * r113207;
double r113212 = r113210 + r113211;
double r113213 = r113209 / r113212;
return r113213;
}
double f(double a, double b, double c, double d) {
double r113214 = b;
double r113215 = c;
double r113216 = r113215 * r113215;
double r113217 = d;
double r113218 = r113217 * r113217;
double r113219 = r113216 + r113218;
double r113220 = sqrt(r113219);
double r113221 = r113220 / r113215;
double r113222 = r113214 / r113221;
double r113223 = a;
double r113224 = r113220 / r113217;
double r113225 = r113223 / r113224;
double r113226 = r113222 - r113225;
double r113227 = r113226 / r113220;
return r113227;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 25.9 |
|---|---|
| Target | 0.5 |
| Herbie | 22.1 |
Initial program 25.9
rmApplied add-sqr-sqrt25.9
Applied associate-/r*25.8
rmApplied div-sub25.8
rmApplied associate-/l*24.0
rmApplied associate-/l*22.1
Final simplification22.1
herbie shell --seed 2020001
(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))))