\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;c \le -1.0148544823210362 \cdot 10^{+76}:\\
\;\;\;\;\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 r2302416 = a;
double r2302417 = c;
double r2302418 = r2302416 * r2302417;
double r2302419 = b;
double r2302420 = d;
double r2302421 = r2302419 * r2302420;
double r2302422 = r2302418 + r2302421;
double r2302423 = r2302417 * r2302417;
double r2302424 = r2302420 * r2302420;
double r2302425 = r2302423 + r2302424;
double r2302426 = r2302422 / r2302425;
return r2302426;
}
double f(double a, double b, double c, double d) {
double r2302427 = c;
double r2302428 = -1.0148544823210362e+76;
bool r2302429 = r2302427 <= r2302428;
double r2302430 = a;
double r2302431 = -r2302430;
double r2302432 = r2302427 * r2302427;
double r2302433 = d;
double r2302434 = r2302433 * r2302433;
double r2302435 = r2302432 + r2302434;
double r2302436 = sqrt(r2302435);
double r2302437 = r2302431 / r2302436;
double r2302438 = b;
double r2302439 = r2302438 * r2302433;
double r2302440 = r2302430 * r2302427;
double r2302441 = r2302439 + r2302440;
double r2302442 = r2302441 / r2302436;
double r2302443 = r2302442 / r2302436;
double r2302444 = r2302429 ? r2302437 : r2302443;
return r2302444;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.2 |
|---|---|
| Target | 0.4 |
| Herbie | 26.1 |
if c < -1.0148544823210362e+76Initial program 37.3
rmApplied add-sqr-sqrt37.3
Applied associate-/r*37.2
Taylor expanded around -inf 37.3
Simplified37.3
if -1.0148544823210362e+76 < c Initial program 23.3
rmApplied add-sqr-sqrt23.3
Applied associate-/r*23.2
Final simplification26.1
herbie shell --seed 2019153
(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))))