\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;c \le -4.002330886974353 \cdot 10^{-17} \lor \neg \left(c \le 3.4366687886863465 \cdot 10^{63}\right):\\
\;\;\;\;\frac{b}{\frac{{c}^{2} + {d}^{2}}{c}} - \frac{a \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot c}{c \cdot c + d \cdot d} - \frac{a}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{d}{\sqrt{c \cdot c + d \cdot d}}\\
\end{array}double code(double a, double b, double c, double d) {
return (((b * c) - (a * d)) / ((c * c) + (d * d)));
}
double code(double a, double b, double c, double d) {
double temp;
if (((c <= -4.002330886974353e-17) || !(c <= 3.4366687886863465e+63))) {
temp = ((b / ((pow(c, 2.0) + pow(d, 2.0)) / c)) - ((a * d) / ((c * c) + (d * d))));
} else {
temp = (((b * c) / ((c * c) + (d * d))) - ((a / sqrt(((c * c) + (d * d)))) * (d / sqrt(((c * c) + (d * d))))));
}
return temp;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.2 |
|---|---|
| Target | 0.4 |
| Herbie | 23.7 |
if c < -4.002330886974353e-17 or 3.4366687886863465e+63 < c Initial program 33.9
rmApplied div-sub33.9
rmApplied associate-/l*30.5
Simplified30.5
if -4.002330886974353e-17 < c < 3.4366687886863465e+63Initial program 19.0
rmApplied div-sub19.0
rmApplied add-sqr-sqrt19.0
Applied times-frac17.2
Final simplification23.7
herbie shell --seed 2020057
(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))))