\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;d \le -5.629499883415199 \cdot 10^{56} \lor \neg \left(d \le 4.7203252537683124 \cdot 10^{115}\right):\\
\;\;\;\;\frac{b \cdot c}{c \cdot c + d \cdot d} - \frac{a}{d + \frac{{c}^{2}}{d}}\\
\mathbf{else}:\\
\;\;\;\;b \cdot \frac{c}{c \cdot c + d \cdot d} - \frac{a}{\frac{{c}^{2} + {d}^{2}}{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 (((d <= -5.629499883415199e+56) || !(d <= 4.720325253768312e+115))) {
VAR = ((double) (((double) (((double) (b * c)) / ((double) (((double) (c * c)) + ((double) (d * d)))))) - ((double) (a / ((double) (d + ((double) (((double) pow(c, 2.0)) / d))))))));
} else {
VAR = ((double) (((double) (b * ((double) (c / ((double) (((double) (c * c)) + ((double) (d * d)))))))) - ((double) (a / ((double) (((double) (((double) pow(c, 2.0)) + ((double) pow(d, 2.0)))) / d))))));
}
return VAR;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.1 |
|---|---|
| Target | 0.5 |
| Herbie | 16.2 |
if d < -5.629499883415199e56 or 4.7203252537683124e115 < d Initial program 38.8
rmApplied div-sub38.8
rmApplied associate-/l*35.6
Simplified35.6
Taylor expanded around 0 17.0
if -5.629499883415199e56 < d < 4.7203252537683124e115Initial program 18.3
rmApplied div-sub18.3
rmApplied associate-/l*17.9
Simplified17.9
rmApplied *-un-lft-identity17.9
Applied times-frac15.7
Simplified15.7
Final simplification16.2
herbie shell --seed 2020169
(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))))