\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 - d \cdot a}}}{\sqrt{c \cdot c + d \cdot d}}double f(double a, double b, double c, double d) {
double r111229 = b;
double r111230 = c;
double r111231 = r111229 * r111230;
double r111232 = a;
double r111233 = d;
double r111234 = r111232 * r111233;
double r111235 = r111231 - r111234;
double r111236 = r111230 * r111230;
double r111237 = r111233 * r111233;
double r111238 = r111236 + r111237;
double r111239 = r111235 / r111238;
return r111239;
}
double f(double a, double b, double c, double d) {
double r111240 = 1.0;
double r111241 = c;
double r111242 = r111241 * r111241;
double r111243 = d;
double r111244 = r111243 * r111243;
double r111245 = r111242 + r111244;
double r111246 = sqrt(r111245);
double r111247 = b;
double r111248 = r111247 * r111241;
double r111249 = a;
double r111250 = r111243 * r111249;
double r111251 = r111248 - r111250;
double r111252 = r111246 / r111251;
double r111253 = r111240 / r111252;
double r111254 = r111253 / r111246;
return r111254;
}




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
Simplified25.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))))