\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;d \leq -2.024796178527634 \cdot 10^{-05} \lor \neg \left(d \leq 7.741980536026424 \cdot 10^{-194}\right):\\
\;\;\;\;\frac{b}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{c}{\sqrt{c \cdot c + d \cdot d}} - \frac{a}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{d}{\sqrt{c \cdot c + d \cdot d}}\\
\mathbf{else}:\\
\;\;\;\;b \cdot \frac{c}{c \cdot c + d \cdot d} - \frac{d \cdot a}{c \cdot c + d \cdot d}\\
\end{array}(FPCore (a b c d) :precision binary64 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
(FPCore (a b c d)
:precision binary64
(if (or (<= d -2.024796178527634e-05) (not (<= d 7.741980536026424e-194)))
(-
(* (/ b (sqrt (+ (* c c) (* d d)))) (/ c (sqrt (+ (* c c) (* d d)))))
(* (/ a (sqrt (+ (* c c) (* d d)))) (/ d (sqrt (+ (* c c) (* d d))))))
(- (* b (/ c (+ (* c c) (* d d)))) (/ (* d a) (+ (* 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) {
double tmp;
if (((d <= -2.024796178527634e-05) || !(d <= 7.741980536026424e-194))) {
tmp = ((double) (((double) ((b / ((double) sqrt(((double) (((double) (c * c)) + ((double) (d * d))))))) * (c / ((double) sqrt(((double) (((double) (c * c)) + ((double) (d * d))))))))) - ((double) ((a / ((double) sqrt(((double) (((double) (c * c)) + ((double) (d * d))))))) * (d / ((double) sqrt(((double) (((double) (c * c)) + ((double) (d * d)))))))))));
} else {
tmp = ((double) (((double) (b * (c / ((double) (((double) (c * c)) + ((double) (d * d))))))) - (((double) (d * a)) / ((double) (((double) (c * c)) + ((double) (d * d)))))));
}
return tmp;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.8 |
|---|---|
| Target | 0.4 |
| Herbie | 23.1 |
if d < -2.02479617852763408e-5 or 7.74198053602642366e-194 < d Initial program 29.1
rmApplied div-sub_binary6429.1
rmApplied add-sqr-sqrt_binary6429.1
Applied times-frac_binary6426.3
rmApplied add-sqr-sqrt_binary6426.3
Applied times-frac_binary6425.2
if -2.02479617852763408e-5 < d < 7.74198053602642366e-194Initial program 21.5
rmApplied div-sub_binary6421.5
rmApplied *-un-lft-identity_binary6421.5
Applied times-frac_binary6418.6
Simplified18.6
Final simplification23.1
herbie shell --seed 2020210
(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))))