\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.1631964723081969 \cdot 10^{+277}:\\
\;\;\;\;\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{-a}{\sqrt{c \cdot c + d \cdot d}}\\
\end{array}double f(double a, double b, double c, double d) {
double r2793720 = b;
double r2793721 = c;
double r2793722 = r2793720 * r2793721;
double r2793723 = a;
double r2793724 = d;
double r2793725 = r2793723 * r2793724;
double r2793726 = r2793722 - r2793725;
double r2793727 = r2793721 * r2793721;
double r2793728 = r2793724 * r2793724;
double r2793729 = r2793727 + r2793728;
double r2793730 = r2793726 / r2793729;
return r2793730;
}
double f(double a, double b, double c, double d) {
double r2793731 = b;
double r2793732 = c;
double r2793733 = r2793731 * r2793732;
double r2793734 = a;
double r2793735 = d;
double r2793736 = r2793734 * r2793735;
double r2793737 = r2793733 - r2793736;
double r2793738 = r2793732 * r2793732;
double r2793739 = r2793735 * r2793735;
double r2793740 = r2793738 + r2793739;
double r2793741 = r2793737 / r2793740;
double r2793742 = 1.1631964723081969e+277;
bool r2793743 = r2793741 <= r2793742;
double r2793744 = sqrt(r2793740);
double r2793745 = r2793737 / r2793744;
double r2793746 = r2793745 / r2793744;
double r2793747 = -r2793734;
double r2793748 = r2793747 / r2793744;
double r2793749 = r2793743 ? r2793746 : r2793748;
return r2793749;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 25.2 |
|---|---|
| Target | 0.5 |
| Herbie | 24.8 |
if (/ (- (* b c) (* a d)) (+ (* c c) (* d d))) < 1.1631964723081969e+277Initial program 13.6
rmApplied add-sqr-sqrt13.6
Applied associate-/r*13.5
if 1.1631964723081969e+277 < (/ (- (* b c) (* a d)) (+ (* c c) (* d d))) Initial program 61.2
rmApplied add-sqr-sqrt61.2
Applied associate-/r*61.2
Taylor expanded around 0 59.9
Simplified59.9
Final simplification24.8
herbie shell --seed 2019129
(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))))