\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 1.126077854837793543272902488688401092988 \cdot 10^{280}:\\
\;\;\;\;\frac{\frac{1}{\frac{\sqrt{c \cdot c + d \cdot d}}{b \cdot d + a \cdot c}}}{\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 r79219 = a;
double r79220 = c;
double r79221 = r79219 * r79220;
double r79222 = b;
double r79223 = d;
double r79224 = r79222 * r79223;
double r79225 = r79221 + r79224;
double r79226 = r79220 * r79220;
double r79227 = r79223 * r79223;
double r79228 = r79226 + r79227;
double r79229 = r79225 / r79228;
return r79229;
}
double f(double a, double b, double c, double d) {
double r79230 = b;
double r79231 = d;
double r79232 = r79230 * r79231;
double r79233 = a;
double r79234 = c;
double r79235 = r79233 * r79234;
double r79236 = r79232 + r79235;
double r79237 = r79234 * r79234;
double r79238 = r79231 * r79231;
double r79239 = r79237 + r79238;
double r79240 = r79236 / r79239;
double r79241 = -inf.0;
bool r79242 = r79240 <= r79241;
double r79243 = sqrt(r79239);
double r79244 = r79230 / r79243;
double r79245 = 1.1260778548377935e+280;
bool r79246 = r79240 <= r79245;
double r79247 = 1.0;
double r79248 = r79243 / r79236;
double r79249 = r79247 / r79248;
double r79250 = r79249 / r79243;
double r79251 = r79233 / r79243;
double r79252 = r79246 ? r79250 : r79251;
double r79253 = r79242 ? r79244 : r79252;
return r79253;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.5 |
|---|---|
| Target | 0.5 |
| Herbie | 25.4 |
if (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))) < -inf.0Initial program 64.0
rmApplied add-sqr-sqrt64.0
Applied associate-/r*64.0
Simplified64.0
Taylor expanded around inf 52.5
if -inf.0 < (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))) < 1.1260778548377935e+280Initial program 11.8
rmApplied add-sqr-sqrt11.8
Applied associate-/r*11.7
Simplified11.7
rmApplied clear-num11.8
if 1.1260778548377935e+280 < (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))) Initial program 62.8
rmApplied add-sqr-sqrt62.8
Applied associate-/r*62.8
Simplified62.8
Taylor expanded around 0 60.1
Final simplification25.4
herbie shell --seed 2019196
(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))))