\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;c \le -1.4263286739610966 \cdot 10^{110}:\\
\;\;\;\;\frac{-1 \cdot a}{\mathsf{hypot}\left(c, d\right) \cdot 1}\\
\mathbf{elif}\;c \le 3.2040013395502375 \cdot 10^{169}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right) \cdot 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right) \cdot 1} \cdot a\\
\end{array}double f(double a, double b, double c, double d) {
double r156906 = a;
double r156907 = c;
double r156908 = r156906 * r156907;
double r156909 = b;
double r156910 = d;
double r156911 = r156909 * r156910;
double r156912 = r156908 + r156911;
double r156913 = r156907 * r156907;
double r156914 = r156910 * r156910;
double r156915 = r156913 + r156914;
double r156916 = r156912 / r156915;
return r156916;
}
double f(double a, double b, double c, double d) {
double r156917 = c;
double r156918 = -1.4263286739610966e+110;
bool r156919 = r156917 <= r156918;
double r156920 = -1.0;
double r156921 = a;
double r156922 = r156920 * r156921;
double r156923 = d;
double r156924 = hypot(r156917, r156923);
double r156925 = 1.0;
double r156926 = r156924 * r156925;
double r156927 = r156922 / r156926;
double r156928 = 3.2040013395502375e+169;
bool r156929 = r156917 <= r156928;
double r156930 = b;
double r156931 = r156930 * r156923;
double r156932 = fma(r156921, r156917, r156931);
double r156933 = r156932 / r156924;
double r156934 = r156933 / r156926;
double r156935 = r156925 / r156926;
double r156936 = r156935 * r156921;
double r156937 = r156929 ? r156934 : r156936;
double r156938 = r156919 ? r156927 : r156937;
return r156938;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
| Original | 25.9 |
|---|---|
| Target | 0.4 |
| Herbie | 12.9 |
if c < -1.4263286739610966e+110Initial program 40.5
rmApplied add-sqr-sqrt40.5
Applied *-un-lft-identity40.5
Applied times-frac40.5
Simplified40.5
Simplified27.0
rmApplied associate-*r/27.0
Simplified27.0
Taylor expanded around -inf 15.6
if -1.4263286739610966e+110 < c < 3.2040013395502375e+169Initial program 19.5
rmApplied add-sqr-sqrt19.5
Applied *-un-lft-identity19.5
Applied times-frac19.5
Simplified19.5
Simplified12.4
rmApplied associate-*r/12.4
Simplified12.3
if 3.2040013395502375e+169 < c Initial program 44.5
rmApplied add-sqr-sqrt44.5
Applied *-un-lft-identity44.5
Applied times-frac44.5
Simplified44.5
Simplified30.1
Taylor expanded around inf 12.7
Final simplification12.9
herbie shell --seed 2020033 +o rules:numerics
(FPCore (a b c d)
:name "Complex division, real part"
:precision binary64
:herbie-target
(if (< (fabs d) (fabs c)) (/ (+ a (* b (/ d c))) (+ c (* d (/ d c)))) (/ (+ b (* a (/ c d))) (+ d (* c (/ c d)))))
(/ (+ (* a c) (* b d)) (+ (* c c) (* d d))))