\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\frac{\frac{b \cdot c - a \cdot d}{\sqrt{c \cdot c + d \cdot d}}}{\sqrt{c \cdot c + d \cdot d}}(FPCore (a b c d) :precision binary64 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
(FPCore (a b c d) :precision binary64 (/ (/ (- (* b c) (* a d)) (sqrt (+ (* c c) (* d d)))) (sqrt (+ (* c c) (* d d)))))
double code(double a, double b, double c, double d) {
return (((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 * c)) - ((double) (a * d)))) / ((double) sqrt(((double) (((double) (c * c)) + ((double) (d * 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 | 26.4 |
|---|---|
| Target | 0.4 |
| Herbie | 26.4 |
Initial program 26.4
rmApplied add-sqr-sqrt_binary6426.4
Applied associate-/r*_binary6426.4
Final simplification26.4
herbie shell --seed 2020219
(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))))