\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;c \le 1.18802561241444503 \cdot 10^{166}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)} \cdot \sqrt{1}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{\mathsf{hypot}\left(c, d\right)} \cdot \sqrt{1}\\
\end{array}double f(double a, double b, double c, double d) {
double r136649 = a;
double r136650 = c;
double r136651 = r136649 * r136650;
double r136652 = b;
double r136653 = d;
double r136654 = r136652 * r136653;
double r136655 = r136651 + r136654;
double r136656 = r136650 * r136650;
double r136657 = r136653 * r136653;
double r136658 = r136656 + r136657;
double r136659 = r136655 / r136658;
return r136659;
}
double f(double a, double b, double c, double d) {
double r136660 = c;
double r136661 = 1.188025612414445e+166;
bool r136662 = r136660 <= r136661;
double r136663 = a;
double r136664 = b;
double r136665 = d;
double r136666 = r136664 * r136665;
double r136667 = fma(r136663, r136660, r136666);
double r136668 = hypot(r136660, r136665);
double r136669 = r136667 / r136668;
double r136670 = r136669 / r136668;
double r136671 = 1.0;
double r136672 = sqrt(r136671);
double r136673 = r136670 * r136672;
double r136674 = r136663 / r136668;
double r136675 = r136674 * r136672;
double r136676 = r136662 ? r136673 : r136675;
return r136676;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
| Original | 26.8 |
|---|---|
| Target | 0.5 |
| Herbie | 15.2 |
if c < 1.188025612414445e+166Initial program 24.2
Simplified24.2
rmApplied add-sqr-sqrt24.2
Applied *-un-lft-identity24.2
Applied times-frac24.2
Simplified24.2
Simplified15.5
rmApplied *-un-lft-identity15.5
Applied add-sqr-sqrt15.5
Applied times-frac15.5
Applied associate-*l*15.5
Simplified15.3
if 1.188025612414445e+166 < c Initial program 46.1
Simplified46.1
rmApplied add-sqr-sqrt46.1
Applied *-un-lft-identity46.1
Applied times-frac46.1
Simplified46.1
Simplified30.2
rmApplied *-un-lft-identity30.2
Applied add-sqr-sqrt30.2
Applied times-frac30.2
Applied associate-*l*30.2
Simplified30.1
Taylor expanded around inf 13.9
Final simplification15.2
herbie shell --seed 2020042 +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))))