\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;d \le 3.241508515477217 \cdot 10^{+87}:\\
\;\;\;\;\frac{b \cdot c - d \cdot a}{d \cdot d + c \cdot c}\\
\mathbf{else}:\\
\;\;\;\;\frac{-a}{\sqrt{d \cdot d + c \cdot c}}\\
\end{array}double f(double a, double b, double c, double d) {
double r4578836 = b;
double r4578837 = c;
double r4578838 = r4578836 * r4578837;
double r4578839 = a;
double r4578840 = d;
double r4578841 = r4578839 * r4578840;
double r4578842 = r4578838 - r4578841;
double r4578843 = r4578837 * r4578837;
double r4578844 = r4578840 * r4578840;
double r4578845 = r4578843 + r4578844;
double r4578846 = r4578842 / r4578845;
return r4578846;
}
double f(double a, double b, double c, double d) {
double r4578847 = d;
double r4578848 = 3.241508515477217e+87;
bool r4578849 = r4578847 <= r4578848;
double r4578850 = b;
double r4578851 = c;
double r4578852 = r4578850 * r4578851;
double r4578853 = a;
double r4578854 = r4578847 * r4578853;
double r4578855 = r4578852 - r4578854;
double r4578856 = r4578847 * r4578847;
double r4578857 = r4578851 * r4578851;
double r4578858 = r4578856 + r4578857;
double r4578859 = r4578855 / r4578858;
double r4578860 = -r4578853;
double r4578861 = sqrt(r4578858);
double r4578862 = r4578860 / r4578861;
double r4578863 = r4578849 ? r4578859 : r4578862;
return r4578863;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 25.4 |
|---|---|
| Target | 0.5 |
| Herbie | 25.2 |
if d < 3.241508515477217e+87Initial program 22.5
if 3.241508515477217e+87 < d Initial program 37.8
rmApplied add-sqr-sqrt37.8
Applied associate-/r*37.8
rmApplied div-inv37.8
Taylor expanded around 0 37.0
Simplified37.0
Final simplification25.2
herbie shell --seed 2019132
(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))))