\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;d \le -5.0306813936220228 \cdot 10^{154}:\\
\;\;\;\;{\left(\frac{\frac{b \cdot c - a \cdot d}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\right)}^{1}\\
\mathbf{elif}\;d \le -7.28046239192008739 \cdot 10^{83}:\\
\;\;\;\;\frac{b}{\frac{\mathsf{fma}\left(c, c, d \cdot d\right)}{c}} - \frac{a}{\frac{\mathsf{fma}\left(c, c, d \cdot d\right)}{d}}\\
\mathbf{elif}\;d \le 3.8050518390474684 \cdot 10^{-78}:\\
\;\;\;\;{\left(\frac{\frac{b \cdot c - a \cdot d}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\right)}^{1}\\
\mathbf{elif}\;d \le 5.27378373520958845 \cdot 10^{-64}:\\
\;\;\;\;{\left(\frac{b}{\mathsf{hypot}\left(c, d\right)}\right)}^{1}\\
\mathbf{elif}\;d \le 1.9537314790331482 \cdot 10^{152}:\\
\;\;\;\;{\left(\frac{\frac{b \cdot c - a \cdot d}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\right)}^{1}\\
\mathbf{else}:\\
\;\;\;\;{\left(\frac{-1 \cdot a}{\mathsf{hypot}\left(c, d\right)}\right)}^{1}\\
\end{array}double f(double a, double b, double c, double d) {
double r110874 = b;
double r110875 = c;
double r110876 = r110874 * r110875;
double r110877 = a;
double r110878 = d;
double r110879 = r110877 * r110878;
double r110880 = r110876 - r110879;
double r110881 = r110875 * r110875;
double r110882 = r110878 * r110878;
double r110883 = r110881 + r110882;
double r110884 = r110880 / r110883;
return r110884;
}
double f(double a, double b, double c, double d) {
double r110885 = d;
double r110886 = -5.030681393622023e+154;
bool r110887 = r110885 <= r110886;
double r110888 = b;
double r110889 = c;
double r110890 = r110888 * r110889;
double r110891 = a;
double r110892 = r110891 * r110885;
double r110893 = r110890 - r110892;
double r110894 = hypot(r110889, r110885);
double r110895 = r110893 / r110894;
double r110896 = r110895 / r110894;
double r110897 = 1.0;
double r110898 = pow(r110896, r110897);
double r110899 = -7.280462391920087e+83;
bool r110900 = r110885 <= r110899;
double r110901 = r110885 * r110885;
double r110902 = fma(r110889, r110889, r110901);
double r110903 = r110902 / r110889;
double r110904 = r110888 / r110903;
double r110905 = r110902 / r110885;
double r110906 = r110891 / r110905;
double r110907 = r110904 - r110906;
double r110908 = 3.8050518390474684e-78;
bool r110909 = r110885 <= r110908;
double r110910 = 5.2737837352095884e-64;
bool r110911 = r110885 <= r110910;
double r110912 = r110888 / r110894;
double r110913 = pow(r110912, r110897);
double r110914 = 1.9537314790331482e+152;
bool r110915 = r110885 <= r110914;
double r110916 = -1.0;
double r110917 = r110916 * r110891;
double r110918 = r110917 / r110894;
double r110919 = pow(r110918, r110897);
double r110920 = r110915 ? r110898 : r110919;
double r110921 = r110911 ? r110913 : r110920;
double r110922 = r110909 ? r110898 : r110921;
double r110923 = r110900 ? r110907 : r110922;
double r110924 = r110887 ? r110898 : r110923;
return r110924;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
| Original | 26.5 |
|---|---|
| Target | 0.4 |
| Herbie | 14.9 |
if d < -5.030681393622023e+154 or -7.280462391920087e+83 < d < 3.8050518390474684e-78 or 5.2737837352095884e-64 < d < 1.9537314790331482e+152Initial program 23.7
rmApplied add-sqr-sqrt23.7
Applied *-un-lft-identity23.7
Applied times-frac23.7
Simplified23.7
Simplified14.9
rmApplied pow114.9
Applied pow114.9
Applied pow-prod-down14.9
Simplified14.8
if -5.030681393622023e+154 < d < -7.280462391920087e+83Initial program 23.7
rmApplied div-sub23.7
Simplified23.7
Simplified15.8
if 3.8050518390474684e-78 < d < 5.2737837352095884e-64Initial program 18.6
rmApplied add-sqr-sqrt18.6
Applied *-un-lft-identity18.6
Applied times-frac18.6
Simplified18.6
Simplified14.2
rmApplied pow114.2
Applied pow114.2
Applied pow-prod-down14.2
Simplified14.1
Taylor expanded around inf 40.5
if 1.9537314790331482e+152 < d Initial program 43.9
rmApplied add-sqr-sqrt43.9
Applied *-un-lft-identity43.9
Applied times-frac43.9
Simplified43.9
Simplified28.2
rmApplied pow128.2
Applied pow128.2
Applied pow-prod-down28.2
Simplified28.2
Taylor expanded around 0 13.2
Final simplification14.9
herbie shell --seed 2020064 +o rules:numerics
(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))))