\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;c \le -2.0951350871904923 \cdot 10^{187}:\\
\;\;\;\;1 \cdot \frac{-1 \cdot b}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \le -4.18745680298238259 \cdot 10^{61}:\\
\;\;\;\;1 \cdot \left(\frac{1}{\sqrt{\mathsf{hypot}\left(c, d\right)}} \cdot \left(\frac{c}{\frac{{\left(\sqrt{\mathsf{hypot}\left(c, d\right)}\right)}^{3}}{b}} - \frac{d}{\frac{{\left(\sqrt{\mathsf{hypot}\left(c, d\right)}\right)}^{3}}{a}}\right)\right)\\
\mathbf{elif}\;c \le 2.1380990366988849 \cdot 10^{168}:\\
\;\;\;\;1 \cdot \frac{\frac{b \cdot c - a \cdot d}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;1 \cdot \frac{b}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}double f(double a, double b, double c, double d) {
double r108876 = b;
double r108877 = c;
double r108878 = r108876 * r108877;
double r108879 = a;
double r108880 = d;
double r108881 = r108879 * r108880;
double r108882 = r108878 - r108881;
double r108883 = r108877 * r108877;
double r108884 = r108880 * r108880;
double r108885 = r108883 + r108884;
double r108886 = r108882 / r108885;
return r108886;
}
double f(double a, double b, double c, double d) {
double r108887 = c;
double r108888 = -2.0951350871904923e+187;
bool r108889 = r108887 <= r108888;
double r108890 = 1.0;
double r108891 = -1.0;
double r108892 = b;
double r108893 = r108891 * r108892;
double r108894 = d;
double r108895 = hypot(r108887, r108894);
double r108896 = r108893 / r108895;
double r108897 = r108890 * r108896;
double r108898 = -4.1874568029823826e+61;
bool r108899 = r108887 <= r108898;
double r108900 = sqrt(r108895);
double r108901 = r108890 / r108900;
double r108902 = 3.0;
double r108903 = pow(r108900, r108902);
double r108904 = r108903 / r108892;
double r108905 = r108887 / r108904;
double r108906 = a;
double r108907 = r108903 / r108906;
double r108908 = r108894 / r108907;
double r108909 = r108905 - r108908;
double r108910 = r108901 * r108909;
double r108911 = r108890 * r108910;
double r108912 = 2.138099036698885e+168;
bool r108913 = r108887 <= r108912;
double r108914 = r108892 * r108887;
double r108915 = r108906 * r108894;
double r108916 = r108914 - r108915;
double r108917 = r108916 / r108895;
double r108918 = r108917 / r108895;
double r108919 = r108890 * r108918;
double r108920 = r108892 / r108895;
double r108921 = r108890 * r108920;
double r108922 = r108913 ? r108919 : r108921;
double r108923 = r108899 ? r108911 : r108922;
double r108924 = r108889 ? r108897 : r108923;
return r108924;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.2 |
|---|---|
| Target | 0.4 |
| Herbie | 11.9 |
if c < -2.0951350871904923e+187Initial program 43.3
rmApplied add-sqr-sqrt43.3
Applied *-un-lft-identity43.3
Applied times-frac43.3
Simplified43.3
Simplified30.7
rmApplied *-un-lft-identity30.7
Applied associate-*l*30.7
Simplified30.7
Taylor expanded around -inf 11.1
if -2.0951350871904923e+187 < c < -4.1874568029823826e+61Initial program 30.5
rmApplied add-sqr-sqrt30.5
Applied *-un-lft-identity30.5
Applied times-frac30.5
Simplified30.5
Simplified19.7
rmApplied *-un-lft-identity19.7
Applied associate-*l*19.7
Simplified19.6
rmApplied *-un-lft-identity19.6
Applied add-sqr-sqrt19.8
Applied *-un-lft-identity19.8
Applied times-frac19.8
Applied times-frac19.8
Simplified19.8
Simplified19.8
rmApplied div-sub19.8
Applied div-sub19.8
Simplified13.6
Simplified11.7
if -4.1874568029823826e+61 < c < 2.138099036698885e+168Initial program 19.7
rmApplied add-sqr-sqrt19.7
Applied *-un-lft-identity19.7
Applied times-frac19.7
Simplified19.7
Simplified12.1
rmApplied *-un-lft-identity12.1
Applied associate-*l*12.1
Simplified12.0
if 2.138099036698885e+168 < c Initial program 44.3
rmApplied add-sqr-sqrt44.3
Applied *-un-lft-identity44.3
Applied times-frac44.3
Simplified44.3
Simplified30.6
rmApplied *-un-lft-identity30.6
Applied associate-*l*30.6
Simplified30.5
Taylor expanded around inf 11.9
Final simplification11.9
herbie shell --seed 2020057 +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))))