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) (((double) (c * c)) + ((double) (d * d)))))))) - ((double) (((double) (a / ((double) sqrt(((double) (((double) (c * c)) + ((double) (d * d)))))))) * ((double) (d / ((double) sqrt(((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 | 27.0 |
|---|---|
| Target | 0.5 |
| Herbie | 23.7 |
Initial program 27.0
rmApplied div-sub27.0
Simplified25.5
Simplified23.6
rmApplied add-sqr-sqrt23.6
Applied *-un-lft-identity23.6
Applied times-frac23.6
Applied associate-*r*23.8
Simplified23.7
Final simplification23.7
herbie shell --seed 2020181
(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))))