\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;d \le -1.351214721549483218261281106569258966909 \cdot 10^{154} \lor \neg \left(d \le 8.000358861136643239312158095843514305232 \cdot 10^{153}\right):\\
\;\;\;\;\frac{b}{\frac{c \cdot c + d \cdot d}{c}} - \frac{a}{d + \frac{{c}^{2}}{d}}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{\frac{{d}^{2}}{c} + c} - \frac{a}{\frac{c \cdot c + d \cdot d}{d}}\\
\end{array}double f(double a, double b, double c, double d) {
double r118903 = b;
double r118904 = c;
double r118905 = r118903 * r118904;
double r118906 = a;
double r118907 = d;
double r118908 = r118906 * r118907;
double r118909 = r118905 - r118908;
double r118910 = r118904 * r118904;
double r118911 = r118907 * r118907;
double r118912 = r118910 + r118911;
double r118913 = r118909 / r118912;
return r118913;
}
double f(double a, double b, double c, double d) {
double r118914 = d;
double r118915 = -1.3512147215494832e+154;
bool r118916 = r118914 <= r118915;
double r118917 = 8.000358861136643e+153;
bool r118918 = r118914 <= r118917;
double r118919 = !r118918;
bool r118920 = r118916 || r118919;
double r118921 = b;
double r118922 = c;
double r118923 = r118922 * r118922;
double r118924 = r118914 * r118914;
double r118925 = r118923 + r118924;
double r118926 = r118925 / r118922;
double r118927 = r118921 / r118926;
double r118928 = a;
double r118929 = 2.0;
double r118930 = pow(r118922, r118929);
double r118931 = r118930 / r118914;
double r118932 = r118914 + r118931;
double r118933 = r118928 / r118932;
double r118934 = r118927 - r118933;
double r118935 = pow(r118914, r118929);
double r118936 = r118935 / r118922;
double r118937 = r118936 + r118922;
double r118938 = r118921 / r118937;
double r118939 = r118925 / r118914;
double r118940 = r118928 / r118939;
double r118941 = r118938 - r118940;
double r118942 = r118920 ? r118934 : r118941;
return r118942;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.5 |
|---|---|
| Target | 0.5 |
| Herbie | 8.6 |
if d < -1.3512147215494832e+154 or 8.000358861136643e+153 < d Initial program 46.6
rmApplied add-sqr-sqrt46.6
rmApplied div-sub46.6
Simplified46.4
Simplified45.3
Taylor expanded around 0 16.8
if -1.3512147215494832e+154 < d < 8.000358861136643e+153Initial program 18.8
rmApplied add-sqr-sqrt18.8
rmApplied div-sub18.8
Simplified17.0
Simplified15.2
Taylor expanded around 0 5.4
Final simplification8.6
herbie shell --seed 2019353
(FPCore (a b c d)
:name "Complex division, imag part"
:precision binary64
: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))))