\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} \le 1.496108978430405 \cdot 10^{296}:\\
\;\;\;\;\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) (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) (b * c)) - ((double) (a * d)))) / ((double) (((double) (c * c)) + ((double) (d * d))))) <= 1.4961089784304048e+296)) {
VAR = ((((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 = (b / ((double) sqrt(((double) (((double) (c * c)) + ((double) (d * d)))))));
}
return VAR;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.0 |
|---|---|
| Target | 0.5 |
| Herbie | 25.2 |
if (/ (- (* b c) (* a d)) (+ (* c c) (* d d))) < 1.496108978430405e296Initial program 13.6
rmApplied add-sqr-sqrt13.6
Applied associate-/r*13.5
if 1.496108978430405e296 < (/ (- (* b c) (* a d)) (+ (* c c) (* d d))) Initial program 63.1
rmApplied add-sqr-sqrt63.1
Applied associate-/r*63.1
Taylor expanded around inf 60.4
Final simplification25.2
herbie shell --seed 2020181
(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))))