\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} \le 6.142565536588697 \cdot 10^{+301}:\\
\;\;\;\;\frac{1}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{b \cdot d + a \cdot c}{\sqrt{c \cdot c + d \cdot d}}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{\sqrt{c \cdot c + d \cdot d}} \cdot a\\
\end{array}double f(double a, double b, double c, double d) {
double r30746077 = a;
double r30746078 = c;
double r30746079 = r30746077 * r30746078;
double r30746080 = b;
double r30746081 = d;
double r30746082 = r30746080 * r30746081;
double r30746083 = r30746079 + r30746082;
double r30746084 = r30746078 * r30746078;
double r30746085 = r30746081 * r30746081;
double r30746086 = r30746084 + r30746085;
double r30746087 = r30746083 / r30746086;
return r30746087;
}
double f(double a, double b, double c, double d) {
double r30746088 = b;
double r30746089 = d;
double r30746090 = r30746088 * r30746089;
double r30746091 = a;
double r30746092 = c;
double r30746093 = r30746091 * r30746092;
double r30746094 = r30746090 + r30746093;
double r30746095 = r30746092 * r30746092;
double r30746096 = r30746089 * r30746089;
double r30746097 = r30746095 + r30746096;
double r30746098 = r30746094 / r30746097;
double r30746099 = 6.142565536588697e+301;
bool r30746100 = r30746098 <= r30746099;
double r30746101 = 1.0;
double r30746102 = sqrt(r30746097);
double r30746103 = r30746101 / r30746102;
double r30746104 = r30746094 / r30746102;
double r30746105 = r30746103 * r30746104;
double r30746106 = -1.0;
double r30746107 = r30746106 / r30746102;
double r30746108 = r30746107 * r30746091;
double r30746109 = r30746100 ? r30746105 : r30746108;
return r30746109;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 25.6 |
|---|---|
| Target | 0.5 |
| Herbie | 25.1 |
if (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))) < 6.142565536588697e+301Initial program 14.1
rmApplied add-sqr-sqrt14.1
Applied *-un-lft-identity14.1
Applied times-frac14.1
if 6.142565536588697e+301 < (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))) Initial program 62.2
rmApplied add-sqr-sqrt62.2
Applied *-un-lft-identity62.2
Applied times-frac62.2
Taylor expanded around -inf 60.0
Simplified60.0
Final simplification25.1
herbie shell --seed 2019124
(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))))