\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} = -inf.0:\\
\;\;\;\;\frac{-1 \cdot b}{\sqrt{c \cdot c + d \cdot d}}\\
\mathbf{elif}\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \le 5.3909740165376935 \cdot 10^{275}:\\
\;\;\;\;\frac{\left(b \cdot c - a \cdot d\right) \cdot \frac{1}{\sqrt{c \cdot c + d \cdot d}}}{\sqrt{c \cdot c + d \cdot d}}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{\sqrt{c \cdot c + d \cdot d}}\\
\end{array}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) {
double VAR;
if ((((double) (((double) (((double) (b * c)) - ((double) (a * d)))) / ((double) (((double) (c * c)) + ((double) (d * d)))))) <= -inf.0)) {
VAR = ((double) (((double) (-1.0 * b)) / ((double) sqrt(((double) (((double) (c * c)) + ((double) (d * d))))))));
} else {
double VAR_1;
if ((((double) (((double) (((double) (b * c)) - ((double) (a * d)))) / ((double) (((double) (c * c)) + ((double) (d * d)))))) <= 5.3909740165376935e+275)) {
VAR_1 = ((double) (((double) (((double) (((double) (b * c)) - ((double) (a * d)))) * ((double) (1.0 / ((double) sqrt(((double) (((double) (c * c)) + ((double) (d * d)))))))))) / ((double) sqrt(((double) (((double) (c * c)) + ((double) (d * d))))))));
} else {
VAR_1 = ((double) (b / ((double) sqrt(((double) (((double) (c * c)) + ((double) (d * d))))))));
}
VAR = VAR_1;
}
return VAR;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 25.7 |
|---|---|
| Target | 0.4 |
| Herbie | 24.8 |
if (/ (- (* b c) (* a d)) (+ (* c c) (* d d))) < -inf.0Initial program 64.0
rmApplied add-sqr-sqrt64.0
Applied associate-/r*64.0
Taylor expanded around -inf 51.2
if -inf.0 < (/ (- (* b c) (* a d)) (+ (* c c) (* d d))) < 5.3909740165376935e275Initial program 12.0
rmApplied add-sqr-sqrt12.0
Applied associate-/r*11.9
rmApplied div-inv12.0
if 5.3909740165376935e275 < (/ (- (* b c) (* a d)) (+ (* c c) (* d d))) Initial program 61.9
rmApplied add-sqr-sqrt61.9
Applied associate-/r*61.9
Taylor expanded around inf 59.8
Final simplification24.8
herbie shell --seed 2020173
(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))))