\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;c \le -8.92963265056487216 \cdot 10^{29}:\\
\;\;\;\;\frac{-1 \cdot b}{\sqrt{c \cdot c + d \cdot d}}\\
\mathbf{elif}\;c \le 1.76178820231422521 \cdot 10^{86}:\\
\;\;\;\;\frac{\frac{b \cdot c - a \cdot d}{\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 ((c <= -8.929632650564872e+29)) {
VAR = ((double) (((double) (-1.0 * b)) / ((double) sqrt(((double) (((double) (c * c)) + ((double) (d * d))))))));
} else {
double VAR_1;
if ((c <= 1.7617882023142252e+86)) {
VAR_1 = ((double) (((double) (((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))))))));
} 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 | 26.3 |
|---|---|
| Target | 0.4 |
| Herbie | 26.6 |
if c < -8.92963265056487216e29Initial program 34.8
rmApplied add-sqr-sqrt34.8
Applied associate-/r*34.8
Taylor expanded around -inf 36.7
if -8.92963265056487216e29 < c < 1.76178820231422521e86Initial program 18.9
rmApplied add-sqr-sqrt18.9
Applied associate-/r*18.8
if 1.76178820231422521e86 < c Initial program 38.3
rmApplied add-sqr-sqrt38.3
Applied associate-/r*38.3
Taylor expanded around inf 38.0
Final simplification26.6
herbie shell --seed 2020161
(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))))