\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 3.0586257786179306 \cdot 10^{292}:\\
\;\;\;\;\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 r86848 = b;
double r86849 = c;
double r86850 = r86848 * r86849;
double r86851 = a;
double r86852 = d;
double r86853 = r86851 * r86852;
double r86854 = r86850 - r86853;
double r86855 = r86849 * r86849;
double r86856 = r86852 * r86852;
double r86857 = r86855 + r86856;
double r86858 = r86854 / r86857;
return r86858;
}
double f(double a, double b, double c, double d) {
double r86859 = b;
double r86860 = c;
double r86861 = r86859 * r86860;
double r86862 = a;
double r86863 = d;
double r86864 = r86862 * r86863;
double r86865 = r86861 - r86864;
double r86866 = r86860 * r86860;
double r86867 = r86863 * r86863;
double r86868 = r86866 + r86867;
double r86869 = r86865 / r86868;
double r86870 = 3.0586257786179306e+292;
bool r86871 = r86869 <= r86870;
double r86872 = sqrt(r86868);
double r86873 = r86865 / r86872;
double r86874 = r86873 / r86872;
double r86875 = r86859 / r86872;
double r86876 = r86871 ? r86874 : r86875;
return r86876;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 25.8 |
|---|---|
| Target | 0.5 |
| Herbie | 25.2 |
if (/ (- (* b c) (* a d)) (+ (* c c) (* d d))) < 3.0586257786179306e+292Initial program 13.9
rmApplied add-sqr-sqrt13.9
Applied associate-/r*13.8
if 3.0586257786179306e+292 < (/ (- (* b c) (* a d)) (+ (* c c) (* d d))) Initial program 63.0
rmApplied add-sqr-sqrt63.0
Applied associate-/r*63.0
Taylor expanded around inf 60.6
Final simplification25.2
herbie shell --seed 2019198
(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))))