\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;\frac{b \cdot d + a \cdot c}{c \cdot c + d \cdot d} = -\infty:\\
\;\;\;\;\frac{b}{\sqrt{c \cdot c + d \cdot d}}\\
\mathbf{elif}\;\frac{b \cdot d + a \cdot c}{c \cdot c + d \cdot d} \le 7.764290901790722 \cdot 10^{+281}:\\
\;\;\;\;\frac{\frac{b \cdot d + a \cdot c}{\sqrt{c \cdot c + d \cdot d}}}{\sqrt{c \cdot c + d \cdot d}}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{\sqrt{c \cdot c + d \cdot d}}\\
\end{array}double f(double a, double b, double c, double d) {
double r15501947 = a;
double r15501948 = c;
double r15501949 = r15501947 * r15501948;
double r15501950 = b;
double r15501951 = d;
double r15501952 = r15501950 * r15501951;
double r15501953 = r15501949 + r15501952;
double r15501954 = r15501948 * r15501948;
double r15501955 = r15501951 * r15501951;
double r15501956 = r15501954 + r15501955;
double r15501957 = r15501953 / r15501956;
return r15501957;
}
double f(double a, double b, double c, double d) {
double r15501958 = b;
double r15501959 = d;
double r15501960 = r15501958 * r15501959;
double r15501961 = a;
double r15501962 = c;
double r15501963 = r15501961 * r15501962;
double r15501964 = r15501960 + r15501963;
double r15501965 = r15501962 * r15501962;
double r15501966 = r15501959 * r15501959;
double r15501967 = r15501965 + r15501966;
double r15501968 = r15501964 / r15501967;
double r15501969 = -inf.0;
bool r15501970 = r15501968 <= r15501969;
double r15501971 = sqrt(r15501967);
double r15501972 = r15501958 / r15501971;
double r15501973 = 7.764290901790722e+281;
bool r15501974 = r15501968 <= r15501973;
double r15501975 = r15501964 / r15501971;
double r15501976 = r15501975 / r15501971;
double r15501977 = r15501961 / r15501971;
double r15501978 = r15501974 ? r15501976 : r15501977;
double r15501979 = r15501970 ? r15501972 : r15501978;
return r15501979;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 25.7 |
|---|---|
| Target | 0.4 |
| Herbie | 25.0 |
if (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))) < -inf.0Initial program 60.5
rmApplied add-sqr-sqrt60.5
Applied associate-/r*60.5
Taylor expanded around 0 53.1
if -inf.0 < (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))) < 7.764290901790722e+281Initial program 11.1
rmApplied add-sqr-sqrt11.1
Applied associate-/r*11.0
if 7.764290901790722e+281 < (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))) Initial program 61.2
rmApplied add-sqr-sqrt61.2
Applied associate-/r*61.2
Taylor expanded around inf 59.7
Final simplification25.0
herbie shell --seed 2019107
(FPCore (a b c d)
:name "Complex division, real part"
: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))))