\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;c \le -1.9332834244083665 \cdot 10^{35} \lor \neg \left(c \le 9.04660525453447799 \cdot 10^{56}\right):\\
\;\;\;\;\frac{b}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{c}{\sqrt{c \cdot c + d \cdot d}} - \frac{a \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot 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 (((c <= -1.9332834244083665e+35) || !(c <= 9.046605254534478e+56))) {
VAR = ((double) (((double) (((double) (b / ((double) sqrt(((double) (((double) (c * c)) + ((double) (d * d)))))))) * ((double) (c / ((double) sqrt(((double) (((double) (c * c)) + ((double) (d * d)))))))))) - ((double) (((double) (a * d)) / ((double) (((double) (c * c)) + ((double) (d * d))))))));
} else {
VAR = ((double) (((double) (((double) (b * 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 | 23.0 |
if c < -1.9332834244083665e+35 or 9.046605254534478e+56 < c Initial program 35.9
rmApplied div-sub35.9
rmApplied add-sqr-sqrt35.9
Applied times-frac32.4
if -1.9332834244083665e+35 < c < 9.046605254534478e+56Initial program 18.2
rmApplied div-sub18.2
rmApplied associate-/l*15.4
Simplified15.4
Final simplification23.0
herbie shell --seed 2020131
(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))))