\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\frac{\frac{c \cdot b - a \cdot 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 r4960218 = b;
double r4960219 = c;
double r4960220 = r4960218 * r4960219;
double r4960221 = a;
double r4960222 = d;
double r4960223 = r4960221 * r4960222;
double r4960224 = r4960220 - r4960223;
double r4960225 = r4960219 * r4960219;
double r4960226 = r4960222 * r4960222;
double r4960227 = r4960225 + r4960226;
double r4960228 = r4960224 / r4960227;
return r4960228;
}
double f(double a, double b, double c, double d) {
double r4960229 = c;
double r4960230 = b;
double r4960231 = r4960229 * r4960230;
double r4960232 = a;
double r4960233 = d;
double r4960234 = r4960232 * r4960233;
double r4960235 = r4960231 - r4960234;
double r4960236 = r4960229 * r4960229;
double r4960237 = r4960233 * r4960233;
double r4960238 = r4960236 + r4960237;
double r4960239 = sqrt(r4960238);
double r4960240 = r4960235 / r4960239;
double r4960241 = r4960240 / r4960239;
return r4960241;
}




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.0 |
Initial program 25.1
rmApplied add-sqr-sqrt25.1
Applied associate-/r*25.0
rmApplied div-inv25.1
rmApplied associate-*r/25.0
Simplified25.0
Final simplification25.0
herbie shell --seed 2019158
(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))))