\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;a \le -2.89329598299196714 \cdot 10^{246}:\\
\;\;\;\;\frac{1}{\frac{c \cdot c + d \cdot d}{b \cdot c - a \cdot d}}\\
\mathbf{elif}\;a \le -1.5666623877864712 \cdot 10^{220}:\\
\;\;\;\;\frac{-1 \cdot a}{\sqrt{c \cdot c + d \cdot d}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{b \cdot c - a \cdot d}{\sqrt{c \cdot c + d \cdot d}}}{\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 ((a <= -2.893295982991967e+246)) {
VAR = ((double) (1.0 / ((double) (((double) (((double) (c * c)) + ((double) (d * d)))) / ((double) (((double) (b * c)) - ((double) (a * d))))))));
} else {
double VAR_1;
if ((a <= -1.5666623877864712e+220)) {
VAR_1 = ((double) (((double) (-1.0 * a)) / ((double) sqrt(((double) (((double) (c * c)) + ((double) (d * d))))))));
} else {
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))))))));
}
VAR = VAR_1;
}
return VAR;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.2 |
|---|---|
| Target | 0.4 |
| Herbie | 26.5 |
if a < -2.893295982991967e+246Initial program 45.3
rmApplied clear-num45.4
if -2.893295982991967e+246 < a < -1.5666623877864712e+220Initial program 34.7
rmApplied add-sqr-sqrt34.7
Applied associate-/r*34.7
Taylor expanded around 0 51.6
if -1.5666623877864712e+220 < a Initial program 25.1
rmApplied add-sqr-sqrt25.1
Applied associate-/r*25.0
Final simplification26.5
herbie shell --seed 2020122
(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))))