\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\frac{\frac{c \cdot b - d \cdot a}{\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 (/ (/ (- (* c b) (* d a)) (sqrt (+ (* c c) (* d d)))) (sqrt (+ (* c c) (* d d)))))
double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
double code(double a, double b, double c, double d) {
return (((c * b) - (d * a)) / sqrt((c * c) + (d * d))) / sqrt((c * c) + (d * d));
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.4 |
|---|---|
| Target | 0.5 |
| Herbie | 26.3 |
Initial program 26.4
rmApplied add-sqr-sqrt_binary64_176226.4
Applied associate-/r*_binary64_184026.3
Simplified26.3
Final simplification26.3
herbie shell --seed 2020288
(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))))