\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;c \le -7.72381449609585197339080432829350912947 \cdot 10^{66}:\\
\;\;\;\;\frac{-1 \cdot a}{\mathsf{hypot}\left(c, d\right) \cdot 1}\\
\mathbf{elif}\;c \le 2.28477586604815435652148617808763730008 \cdot 10^{70}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right) \cdot 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{\mathsf{hypot}\left(c, d\right) \cdot 1}\\
\end{array}double f(double a, double b, double c, double d) {
double r105613 = a;
double r105614 = c;
double r105615 = r105613 * r105614;
double r105616 = b;
double r105617 = d;
double r105618 = r105616 * r105617;
double r105619 = r105615 + r105618;
double r105620 = r105614 * r105614;
double r105621 = r105617 * r105617;
double r105622 = r105620 + r105621;
double r105623 = r105619 / r105622;
return r105623;
}
double f(double a, double b, double c, double d) {
double r105624 = c;
double r105625 = -7.723814496095852e+66;
bool r105626 = r105624 <= r105625;
double r105627 = -1.0;
double r105628 = a;
double r105629 = r105627 * r105628;
double r105630 = d;
double r105631 = hypot(r105624, r105630);
double r105632 = 1.0;
double r105633 = r105631 * r105632;
double r105634 = r105629 / r105633;
double r105635 = 2.2847758660481544e+70;
bool r105636 = r105624 <= r105635;
double r105637 = b;
double r105638 = r105637 * r105630;
double r105639 = fma(r105628, r105624, r105638);
double r105640 = r105639 / r105631;
double r105641 = r105640 / r105633;
double r105642 = r105628 / r105633;
double r105643 = r105636 ? r105641 : r105642;
double r105644 = r105626 ? r105634 : r105643;
return r105644;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
| Original | 25.9 |
|---|---|
| Target | 0.5 |
| Herbie | 13.6 |
if c < -7.723814496095852e+66Initial program 36.2
rmApplied add-sqr-sqrt36.2
Applied *-un-lft-identity36.2
Applied times-frac36.2
Simplified36.2
Simplified24.1
rmApplied associate-*r/24.1
Simplified24.0
Taylor expanded around -inf 18.2
if -7.723814496095852e+66 < c < 2.2847758660481544e+70Initial program 18.0
rmApplied add-sqr-sqrt18.0
Applied *-un-lft-identity18.0
Applied times-frac18.0
Simplified18.0
Simplified10.6
rmApplied associate-*r/10.5
Simplified10.5
if 2.2847758660481544e+70 < c Initial program 37.9
rmApplied add-sqr-sqrt37.9
Applied *-un-lft-identity37.9
Applied times-frac37.9
Simplified37.9
Simplified25.3
rmApplied associate-*r/25.3
Simplified25.2
Taylor expanded around inf 18.1
Final simplification13.6
herbie shell --seed 2019353 +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))))