\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\frac{\frac{1}{\sqrt{c \cdot c + d \cdot d}}}{\frac{\sqrt{c \cdot c + d \cdot d}}{c \cdot b - d \cdot a}}(FPCore (a b c d) :precision binary64 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
(FPCore (a b c d) :precision binary64 (/ (/ 1.0 (sqrt (+ (* c c) (* d d)))) (/ (sqrt (+ (* c c) (* d d))) (- (* c b) (* d a)))))
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 (1.0 / sqrt((c * c) + (d * d))) / (sqrt((c * c) + (d * d)) / ((c * b) - (d * a)));
}




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.4 |
Initial program 26.4
rmApplied clear-num_binary64_277226.6
rmApplied *-un-lft-identity_binary64_277326.6
Applied add-sqr-sqrt_binary64_279426.6
Applied times-frac_binary64_277926.6
Applied associate-/r*_binary64_271926.4
Simplified26.4
Final simplification26.4
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))))