\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;c \le -2.760768008240295 \cdot 10^{135}:\\
\;\;\;\;\frac{-1 \cdot a}{\mathsf{hypot}\left(c, d\right) \cdot 1}\\
\mathbf{elif}\;c \le 5.258979463944342 \cdot 10^{219}:\\
\;\;\;\;\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 r90631 = a;
double r90632 = c;
double r90633 = r90631 * r90632;
double r90634 = b;
double r90635 = d;
double r90636 = r90634 * r90635;
double r90637 = r90633 + r90636;
double r90638 = r90632 * r90632;
double r90639 = r90635 * r90635;
double r90640 = r90638 + r90639;
double r90641 = r90637 / r90640;
return r90641;
}
double f(double a, double b, double c, double d) {
double r90642 = c;
double r90643 = -2.760768008240295e+135;
bool r90644 = r90642 <= r90643;
double r90645 = -1.0;
double r90646 = a;
double r90647 = r90645 * r90646;
double r90648 = d;
double r90649 = hypot(r90642, r90648);
double r90650 = 1.0;
double r90651 = r90649 * r90650;
double r90652 = r90647 / r90651;
double r90653 = 5.258979463944342e+219;
bool r90654 = r90642 <= r90653;
double r90655 = b;
double r90656 = r90655 * r90648;
double r90657 = fma(r90646, r90642, r90656);
double r90658 = r90657 / r90649;
double r90659 = r90658 / r90651;
double r90660 = r90646 / r90651;
double r90661 = r90654 ? r90659 : r90660;
double r90662 = r90644 ? r90652 : r90661;
return r90662;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
| Original | 25.9 |
|---|---|
| Target | 0.5 |
| Herbie | 13.0 |
if c < -2.760768008240295e+135Initial program 42.9
rmApplied add-sqr-sqrt42.9
Applied *-un-lft-identity42.9
Applied times-frac42.9
Simplified42.9
Simplified29.0
rmApplied associate-*r/29.0
Simplified28.9
Taylor expanded around -inf 14.6
if -2.760768008240295e+135 < c < 5.258979463944342e+219Initial program 21.1
rmApplied add-sqr-sqrt21.1
Applied *-un-lft-identity21.1
Applied times-frac21.1
Simplified21.1
Simplified13.2
rmApplied associate-*r/13.2
Simplified13.1
if 5.258979463944342e+219 < c Initial program 41.8
rmApplied add-sqr-sqrt41.8
Applied *-un-lft-identity41.8
Applied times-frac41.8
Simplified41.8
Simplified31.2
rmApplied associate-*r/31.2
Simplified31.2
Taylor expanded around inf 8.8
Final simplification13.0
herbie shell --seed 2020003 +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))))