\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{b}{\sqrt{c \cdot c + d \cdot d}}\\
\mathbf{elif}\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \le 8.4881995002292849 \cdot 10^{286}:\\
\;\;\;\;\frac{\frac{b \cdot c - a \cdot d}{\sqrt{c \cdot c + d \cdot d}}}{\sqrt{c \cdot c + d \cdot d}}\\
\mathbf{else}:\\
\;\;\;\;e^{\log b - \log c}\\
\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) (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)))))) <= 8.488199500229285e+286)) {
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) exp(((double) (((double) log(b)) - ((double) log(c))))));
}
VAR = VAR_1;
}
return VAR;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.1 |
|---|---|
| Target | 0.4 |
| Herbie | 24.4 |
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 55.5
if -inf.0 < (/ (- (* b c) (* a d)) (+ (* c c) (* d d))) < 8.488199500229285e+286Initial program 11.6
rmApplied add-sqr-sqrt11.6
Applied associate-/r*11.5
if 8.488199500229285e+286 < (/ (- (* b c) (* a d)) (+ (* c c) (* d d))) Initial program 63.0
rmApplied add-exp-log63.0
Applied add-exp-log63.1
Applied div-exp63.1
Simplified63.1
Taylor expanded around inf 57.6
Simplified57.6
Final simplification24.4
herbie shell --seed 2020128
(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))))