\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \le 2.846399672864898633139753001838080406359 \cdot 10^{282}:\\
\;\;\;\;\frac{\frac{1}{\frac{\mathsf{hypot}\left(c, d\right)}{\mathsf{fma}\left(a, c, b \cdot d\right)}}}{\mathsf{hypot}\left(c, d\right) \cdot 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{\mathsf{hypot}\left(c, d\right) \cdot 1}\\
\end{array}double f(double a, double b, double c, double d) {
double r101434 = a;
double r101435 = c;
double r101436 = r101434 * r101435;
double r101437 = b;
double r101438 = d;
double r101439 = r101437 * r101438;
double r101440 = r101436 + r101439;
double r101441 = r101435 * r101435;
double r101442 = r101438 * r101438;
double r101443 = r101441 + r101442;
double r101444 = r101440 / r101443;
return r101444;
}
double f(double a, double b, double c, double d) {
double r101445 = a;
double r101446 = c;
double r101447 = r101445 * r101446;
double r101448 = b;
double r101449 = d;
double r101450 = r101448 * r101449;
double r101451 = r101447 + r101450;
double r101452 = r101446 * r101446;
double r101453 = r101449 * r101449;
double r101454 = r101452 + r101453;
double r101455 = r101451 / r101454;
double r101456 = 2.8463996728648986e+282;
bool r101457 = r101455 <= r101456;
double r101458 = 1.0;
double r101459 = hypot(r101446, r101449);
double r101460 = fma(r101445, r101446, r101450);
double r101461 = r101459 / r101460;
double r101462 = r101458 / r101461;
double r101463 = r101459 * r101458;
double r101464 = r101462 / r101463;
double r101465 = r101448 / r101463;
double r101466 = r101457 ? r101464 : r101465;
return r101466;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
| Original | 26.0 |
|---|---|
| Target | 0.5 |
| Herbie | 13.9 |
if (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))) < 2.8463996728648986e+282Initial program 14.1
rmApplied add-sqr-sqrt14.1
Applied *-un-lft-identity14.1
Applied times-frac14.1
Simplified14.1
Simplified2.9
rmApplied associate-*r/2.8
Simplified2.7
rmApplied clear-num2.8
if 2.8463996728648986e+282 < (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))) Initial program 62.9
rmApplied add-sqr-sqrt62.9
Applied *-un-lft-identity62.9
Applied times-frac62.9
Simplified62.9
Simplified60.3
rmApplied associate-*r/60.3
Simplified60.3
Taylor expanded around 0 48.4
Final simplification13.9
herbie shell --seed 2019362 +o rules:numerics
(FPCore (a b c d)
:name "Complex division, real part"
:precision binary64
: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))))