\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 5.836032336515321 \cdot 10^{+282}:\\
\;\;\;\;\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{b}{\sqrt{c \cdot c + d \cdot d}}\\
\end{array}double f(double a, double b, double c, double d) {
double r3626208 = a;
double r3626209 = c;
double r3626210 = r3626208 * r3626209;
double r3626211 = b;
double r3626212 = d;
double r3626213 = r3626211 * r3626212;
double r3626214 = r3626210 + r3626213;
double r3626215 = r3626209 * r3626209;
double r3626216 = r3626212 * r3626212;
double r3626217 = r3626215 + r3626216;
double r3626218 = r3626214 / r3626217;
return r3626218;
}
double f(double a, double b, double c, double d) {
double r3626219 = b;
double r3626220 = d;
double r3626221 = r3626219 * r3626220;
double r3626222 = a;
double r3626223 = c;
double r3626224 = r3626222 * r3626223;
double r3626225 = r3626221 + r3626224;
double r3626226 = r3626223 * r3626223;
double r3626227 = r3626220 * r3626220;
double r3626228 = r3626226 + r3626227;
double r3626229 = r3626225 / r3626228;
double r3626230 = 5.836032336515321e+282;
bool r3626231 = r3626229 <= r3626230;
double r3626232 = sqrt(r3626228);
double r3626233 = r3626225 / r3626232;
double r3626234 = r3626233 / r3626232;
double r3626235 = r3626219 / r3626232;
double r3626236 = r3626231 ? r3626234 : r3626235;
return r3626236;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 25.9 |
|---|---|
| Target | 0.5 |
| Herbie | 25.7 |
if (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))) < 5.836032336515321e+282Initial program 14.1
rmApplied add-sqr-sqrt14.1
Applied associate-/r*14.0
if 5.836032336515321e+282 < (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))) Initial program 61.0
rmApplied add-sqr-sqrt61.0
Applied associate-/r*61.0
Taylor expanded around 0 60.2
Final simplification25.7
herbie shell --seed 2019149
(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))))