\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\frac{b}{c + d \cdot \frac{d}{c}} - a \cdot \frac{d}{c \cdot c + d \cdot d}double code(double a, double b, double c, double d) {
return ((double) (((double) (((double) (b * c)) - ((double) (a * d)))) / ((double) (((double) (c * c)) + ((double) (d * d))))));
}
double code(double a, double b, double c, double d) {
return ((double) (((double) (b / ((double) (c + ((double) (d * ((double) (d / c)))))))) - ((double) (a * ((double) (d / ((double) (((double) (c * c)) + ((double) (d * d))))))))));
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.2 |
|---|---|
| Target | 0.5 |
| Herbie | 14.2 |
Initial program 26.2
rmApplied div-sub26.2
Simplified24.9
Simplified23.3
rmApplied clear-num23.3
Taylor expanded around 0 15.9
Simplified14.3
rmApplied un-div-inv14.2
Final simplification14.2
herbie shell --seed 2020184
(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)))) (/ (+ (neg a) (* b (/ c d))) (+ d (* c (/ c d)))))
(/ (- (* b c) (* a d)) (+ (* c c) (* d d))))