\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} \le 8.391246277230149 \cdot 10^{+244}:\\
\;\;\;\;\frac{b \cdot d + a \cdot c}{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 r3659700 = a;
double r3659701 = c;
double r3659702 = r3659700 * r3659701;
double r3659703 = b;
double r3659704 = d;
double r3659705 = r3659703 * r3659704;
double r3659706 = r3659702 + r3659705;
double r3659707 = r3659701 * r3659701;
double r3659708 = r3659704 * r3659704;
double r3659709 = r3659707 + r3659708;
double r3659710 = r3659706 / r3659709;
return r3659710;
}
double f(double a, double b, double c, double d) {
double r3659711 = b;
double r3659712 = d;
double r3659713 = r3659711 * r3659712;
double r3659714 = a;
double r3659715 = c;
double r3659716 = r3659714 * r3659715;
double r3659717 = r3659713 + r3659716;
double r3659718 = r3659715 * r3659715;
double r3659719 = r3659712 * r3659712;
double r3659720 = r3659718 + r3659719;
double r3659721 = r3659717 / r3659720;
double r3659722 = 8.391246277230149e+244;
bool r3659723 = r3659721 <= r3659722;
double r3659724 = -r3659714;
double r3659725 = sqrt(r3659720);
double r3659726 = r3659724 / r3659725;
double r3659727 = r3659723 ? r3659721 : r3659726;
return r3659727;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.2 |
|---|---|
| Target | 0.5 |
| Herbie | 26.3 |
if (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))) < 8.391246277230149e+244Initial program 14.2
if 8.391246277230149e+244 < (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))) Initial program 59.2
rmApplied add-sqr-sqrt59.2
Applied associate-/r*59.2
Taylor expanded around -inf 59.7
Simplified59.7
Final simplification26.3
herbie shell --seed 2019141
(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))))