\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;\frac{b \cdot d + a \cdot c}{c \cdot c + d \cdot d} = -\infty:\\
\;\;\;\;\frac{b}{\sqrt{c \cdot c + d \cdot d}}\\
\mathbf{elif}\;\frac{b \cdot d + a \cdot c}{c \cdot c + d \cdot d} \le 7.764290901790722 \cdot 10^{+281}:\\
\;\;\;\;\frac{\frac{b \cdot d + a \cdot c}{\sqrt{c \cdot c + d \cdot d}}}{\sqrt{c \cdot c + d \cdot d}}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{\sqrt{c \cdot c + d \cdot d}}\\
\end{array}double f(double a, double b, double c, double d) {
double r28698772 = a;
double r28698773 = c;
double r28698774 = r28698772 * r28698773;
double r28698775 = b;
double r28698776 = d;
double r28698777 = r28698775 * r28698776;
double r28698778 = r28698774 + r28698777;
double r28698779 = r28698773 * r28698773;
double r28698780 = r28698776 * r28698776;
double r28698781 = r28698779 + r28698780;
double r28698782 = r28698778 / r28698781;
return r28698782;
}
double f(double a, double b, double c, double d) {
double r28698783 = b;
double r28698784 = d;
double r28698785 = r28698783 * r28698784;
double r28698786 = a;
double r28698787 = c;
double r28698788 = r28698786 * r28698787;
double r28698789 = r28698785 + r28698788;
double r28698790 = r28698787 * r28698787;
double r28698791 = r28698784 * r28698784;
double r28698792 = r28698790 + r28698791;
double r28698793 = r28698789 / r28698792;
double r28698794 = -inf.0;
bool r28698795 = r28698793 <= r28698794;
double r28698796 = sqrt(r28698792);
double r28698797 = r28698783 / r28698796;
double r28698798 = 7.764290901790722e+281;
bool r28698799 = r28698793 <= r28698798;
double r28698800 = r28698789 / r28698796;
double r28698801 = r28698800 / r28698796;
double r28698802 = r28698786 / r28698796;
double r28698803 = r28698799 ? r28698801 : r28698802;
double r28698804 = r28698795 ? r28698797 : r28698803;
return r28698804;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 25.7 |
|---|---|
| Target | 0.4 |
| Herbie | 25.0 |
if (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))) < -inf.0Initial program 60.5
rmApplied add-sqr-sqrt60.5
Applied associate-/r*60.5
Taylor expanded around 0 53.1
if -inf.0 < (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))) < 7.764290901790722e+281Initial program 11.1
rmApplied add-sqr-sqrt11.1
Applied associate-/r*11.0
if 7.764290901790722e+281 < (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))) Initial program 61.2
rmApplied add-sqr-sqrt61.2
Applied associate-/r*61.2
Taylor expanded around inf 59.7
Final simplification25.0
herbie shell --seed 2019107
(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))))