\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;c \le 3.74842986632685600906042104748652145254 \cdot 10^{86}:\\
\;\;\;\;\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 f(double a, double b, double c, double d) {
double r115583 = b;
double r115584 = c;
double r115585 = r115583 * r115584;
double r115586 = a;
double r115587 = d;
double r115588 = r115586 * r115587;
double r115589 = r115585 - r115588;
double r115590 = r115584 * r115584;
double r115591 = r115587 * r115587;
double r115592 = r115590 + r115591;
double r115593 = r115589 / r115592;
return r115593;
}
double f(double a, double b, double c, double d) {
double r115594 = c;
double r115595 = 3.748429866326856e+86;
bool r115596 = r115594 <= r115595;
double r115597 = b;
double r115598 = r115597 * r115594;
double r115599 = a;
double r115600 = d;
double r115601 = r115599 * r115600;
double r115602 = r115598 - r115601;
double r115603 = r115594 * r115594;
double r115604 = r115600 * r115600;
double r115605 = r115603 + r115604;
double r115606 = sqrt(r115605);
double r115607 = r115602 / r115606;
double r115608 = r115607 / r115606;
double r115609 = r115597 / r115606;
double r115610 = r115596 ? r115608 : r115609;
return r115610;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.0 |
|---|---|
| Target | 0.3 |
| Herbie | 25.8 |
if c < 3.748429866326856e+86Initial program 22.7
rmApplied add-sqr-sqrt22.7
Applied associate-/r*22.6
if 3.748429866326856e+86 < c Initial program 39.8
rmApplied add-sqr-sqrt39.8
Applied associate-/r*39.7
Taylor expanded around inf 38.9
Final simplification25.8
herbie shell --seed 2019362
(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))))