\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;c \le -4.876668595961939 \cdot 10^{+48}:\\
\;\;\;\;\frac{-a}{\sqrt{c \cdot c + d \cdot d}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{b \cdot d + a \cdot c}{\sqrt{c \cdot c + d \cdot d}}}{\sqrt{c \cdot c + d \cdot d}}\\
\end{array}double f(double a, double b, double c, double d) {
double r3488155 = a;
double r3488156 = c;
double r3488157 = r3488155 * r3488156;
double r3488158 = b;
double r3488159 = d;
double r3488160 = r3488158 * r3488159;
double r3488161 = r3488157 + r3488160;
double r3488162 = r3488156 * r3488156;
double r3488163 = r3488159 * r3488159;
double r3488164 = r3488162 + r3488163;
double r3488165 = r3488161 / r3488164;
return r3488165;
}
double f(double a, double b, double c, double d) {
double r3488166 = c;
double r3488167 = -4.876668595961939e+48;
bool r3488168 = r3488166 <= r3488167;
double r3488169 = a;
double r3488170 = -r3488169;
double r3488171 = r3488166 * r3488166;
double r3488172 = d;
double r3488173 = r3488172 * r3488172;
double r3488174 = r3488171 + r3488173;
double r3488175 = sqrt(r3488174);
double r3488176 = r3488170 / r3488175;
double r3488177 = b;
double r3488178 = r3488177 * r3488172;
double r3488179 = r3488169 * r3488166;
double r3488180 = r3488178 + r3488179;
double r3488181 = r3488180 / r3488175;
double r3488182 = r3488181 / r3488175;
double r3488183 = r3488168 ? r3488176 : r3488182;
return r3488183;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 25.8 |
|---|---|
| Target | 0.4 |
| Herbie | 26.1 |
if c < -4.876668595961939e+48Initial program 35.1
rmApplied add-sqr-sqrt35.1
Applied associate-/r*35.1
Taylor expanded around -inf 36.8
Simplified36.8
if -4.876668595961939e+48 < c Initial program 23.1
rmApplied add-sqr-sqrt23.1
Applied associate-/r*23.0
Final simplification26.1
herbie shell --seed 2019138
(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))))