\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;c \le -1.304579087607779 \cdot 10^{+161}:\\
\;\;\;\;\frac{b \cdot c - d \cdot a}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{1}{\mathsf{hypot}\left(d, c\right)}\\
\mathbf{elif}\;c \le -7.011154002702933 \cdot 10^{+91}:\\
\;\;\;\;\frac{-b}{\sqrt{\mathsf{fma}\left(d, d, c \cdot c\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot c - d \cdot a}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{1}{\mathsf{hypot}\left(d, c\right)}\\
\end{array}double f(double a, double b, double c, double d) {
double r5548867 = b;
double r5548868 = c;
double r5548869 = r5548867 * r5548868;
double r5548870 = a;
double r5548871 = d;
double r5548872 = r5548870 * r5548871;
double r5548873 = r5548869 - r5548872;
double r5548874 = r5548868 * r5548868;
double r5548875 = r5548871 * r5548871;
double r5548876 = r5548874 + r5548875;
double r5548877 = r5548873 / r5548876;
return r5548877;
}
double f(double a, double b, double c, double d) {
double r5548878 = c;
double r5548879 = -1.304579087607779e+161;
bool r5548880 = r5548878 <= r5548879;
double r5548881 = b;
double r5548882 = r5548881 * r5548878;
double r5548883 = d;
double r5548884 = a;
double r5548885 = r5548883 * r5548884;
double r5548886 = r5548882 - r5548885;
double r5548887 = hypot(r5548883, r5548878);
double r5548888 = r5548886 / r5548887;
double r5548889 = 1.0;
double r5548890 = r5548889 / r5548887;
double r5548891 = r5548888 * r5548890;
double r5548892 = -7.011154002702933e+91;
bool r5548893 = r5548878 <= r5548892;
double r5548894 = -r5548881;
double r5548895 = r5548878 * r5548878;
double r5548896 = fma(r5548883, r5548883, r5548895);
double r5548897 = sqrt(r5548896);
double r5548898 = r5548894 / r5548897;
double r5548899 = r5548893 ? r5548898 : r5548891;
double r5548900 = r5548880 ? r5548891 : r5548899;
return r5548900;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
| Original | 26.5 |
|---|---|
| Target | 0.5 |
| Herbie | 17.6 |
if c < -1.304579087607779e+161 or -7.011154002702933e+91 < c Initial program 26.5
Simplified26.5
rmApplied fma-neg26.5
rmApplied clear-num26.6
Simplified26.6
rmApplied *-un-lft-identity26.6
Applied add-sqr-sqrt26.6
Applied times-frac26.6
Applied add-cube-cbrt26.6
Applied times-frac26.5
Simplified26.5
Simplified17.1
if -1.304579087607779e+161 < c < -7.011154002702933e+91Initial program 27.0
Simplified27.0
rmApplied add-sqr-sqrt27.0
Applied associate-/r*26.9
Taylor expanded around -inf 25.8
Simplified25.8
Final simplification17.6
herbie shell --seed 2019165 +o rules:numerics
(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))))