\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;a \le 6.495480430581795464113836761587821513134 \cdot 10^{224}:\\
\;\;\;\;\frac{\frac{b \cdot d + c \cdot a}{\sqrt{d \cdot d + c \cdot c}}}{\sqrt{d \cdot d + c \cdot c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{-a}{\sqrt{d \cdot d + c \cdot c}}\\
\end{array}double f(double a, double b, double c, double d) {
double r5908121 = a;
double r5908122 = c;
double r5908123 = r5908121 * r5908122;
double r5908124 = b;
double r5908125 = d;
double r5908126 = r5908124 * r5908125;
double r5908127 = r5908123 + r5908126;
double r5908128 = r5908122 * r5908122;
double r5908129 = r5908125 * r5908125;
double r5908130 = r5908128 + r5908129;
double r5908131 = r5908127 / r5908130;
return r5908131;
}
double f(double a, double b, double c, double d) {
double r5908132 = a;
double r5908133 = 6.4954804305817955e+224;
bool r5908134 = r5908132 <= r5908133;
double r5908135 = b;
double r5908136 = d;
double r5908137 = r5908135 * r5908136;
double r5908138 = c;
double r5908139 = r5908138 * r5908132;
double r5908140 = r5908137 + r5908139;
double r5908141 = r5908136 * r5908136;
double r5908142 = r5908138 * r5908138;
double r5908143 = r5908141 + r5908142;
double r5908144 = sqrt(r5908143);
double r5908145 = r5908140 / r5908144;
double r5908146 = r5908145 / r5908144;
double r5908147 = -r5908132;
double r5908148 = r5908147 / r5908144;
double r5908149 = r5908134 ? r5908146 : r5908148;
return r5908149;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.6 |
|---|---|
| Target | 0.5 |
| Herbie | 27.2 |
if a < 6.4954804305817955e+224Initial program 25.6
rmApplied add-sqr-sqrt25.6
Applied associate-/r*25.5
if 6.4954804305817955e+224 < a Initial program 42.0
rmApplied add-sqr-sqrt42.0
Applied associate-/r*41.9
Taylor expanded around -inf 52.0
Simplified52.0
Final simplification27.2
herbie shell --seed 2019171
(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))))