\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;c \le -8.222702384414015 \cdot 10^{+149}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;c \le 2.1496090707043887 \cdot 10^{+133}:\\
\;\;\;\;\frac{\frac{b \cdot c - d \cdot a}{\sqrt{c \cdot c + d \cdot d}}}{\sqrt{c \cdot c + d \cdot d}}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}double f(double a, double b, double c, double d) {
double r4837913 = b;
double r4837914 = c;
double r4837915 = r4837913 * r4837914;
double r4837916 = a;
double r4837917 = d;
double r4837918 = r4837916 * r4837917;
double r4837919 = r4837915 - r4837918;
double r4837920 = r4837914 * r4837914;
double r4837921 = r4837917 * r4837917;
double r4837922 = r4837920 + r4837921;
double r4837923 = r4837919 / r4837922;
return r4837923;
}
double f(double a, double b, double c, double d) {
double r4837924 = c;
double r4837925 = -8.222702384414015e+149;
bool r4837926 = r4837924 <= r4837925;
double r4837927 = b;
double r4837928 = r4837927 / r4837924;
double r4837929 = 2.1496090707043887e+133;
bool r4837930 = r4837924 <= r4837929;
double r4837931 = r4837927 * r4837924;
double r4837932 = d;
double r4837933 = a;
double r4837934 = r4837932 * r4837933;
double r4837935 = r4837931 - r4837934;
double r4837936 = r4837924 * r4837924;
double r4837937 = r4837932 * r4837932;
double r4837938 = r4837936 + r4837937;
double r4837939 = sqrt(r4837938);
double r4837940 = r4837935 / r4837939;
double r4837941 = r4837940 / r4837939;
double r4837942 = r4837930 ? r4837941 : r4837928;
double r4837943 = r4837926 ? r4837928 : r4837942;
return r4837943;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 25.7 |
|---|---|
| Target | 0.4 |
| Herbie | 17.3 |
if c < -8.222702384414015e+149 or 2.1496090707043887e+133 < c Initial program 42.8
rmApplied add-sqr-sqrt42.8
Applied associate-/r*42.8
Taylor expanded around inf 42.4
Taylor expanded around inf 14.1
if -8.222702384414015e+149 < c < 2.1496090707043887e+133Initial program 18.7
rmApplied add-sqr-sqrt18.7
Applied associate-/r*18.6
Final simplification17.3
herbie shell --seed 2019168
(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))))