\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;c \le 6.443252805869156 \cdot 10^{+104}:\\
\;\;\;\;\frac{\frac{b \cdot c - a \cdot d}{\sqrt{d \cdot d + c \cdot c}}}{\sqrt{d \cdot d + c \cdot c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{\sqrt{d \cdot d + c \cdot c}}\\
\end{array}double f(double a, double b, double c, double d) {
double r12491585 = b;
double r12491586 = c;
double r12491587 = r12491585 * r12491586;
double r12491588 = a;
double r12491589 = d;
double r12491590 = r12491588 * r12491589;
double r12491591 = r12491587 - r12491590;
double r12491592 = r12491586 * r12491586;
double r12491593 = r12491589 * r12491589;
double r12491594 = r12491592 + r12491593;
double r12491595 = r12491591 / r12491594;
return r12491595;
}
double f(double a, double b, double c, double d) {
double r12491596 = c;
double r12491597 = 6.443252805869156e+104;
bool r12491598 = r12491596 <= r12491597;
double r12491599 = b;
double r12491600 = r12491599 * r12491596;
double r12491601 = a;
double r12491602 = d;
double r12491603 = r12491601 * r12491602;
double r12491604 = r12491600 - r12491603;
double r12491605 = r12491602 * r12491602;
double r12491606 = r12491596 * r12491596;
double r12491607 = r12491605 + r12491606;
double r12491608 = sqrt(r12491607);
double r12491609 = r12491604 / r12491608;
double r12491610 = r12491609 / r12491608;
double r12491611 = r12491599 / r12491608;
double r12491612 = r12491598 ? r12491610 : r12491611;
return r12491612;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 25.6 |
|---|---|
| Target | 0.4 |
| Herbie | 25.5 |
if c < 6.443252805869156e+104Initial program 22.4
rmApplied add-sqr-sqrt22.4
Applied associate-/r*22.4
if 6.443252805869156e+104 < c Initial program 41.1
rmApplied add-sqr-sqrt41.1
Applied associate-/r*41.0
Taylor expanded around inf 40.7
Final simplification25.5
herbie shell --seed 2019104
(FPCore (a b c d)
:name "Complex division, imag part"
: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))))