\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \le 1.4994875845408422 \cdot 10^{+304}:\\
\;\;\;\;\frac{\frac{b \cdot c - a \cdot d}{\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 r4737352 = b;
double r4737353 = c;
double r4737354 = r4737352 * r4737353;
double r4737355 = a;
double r4737356 = d;
double r4737357 = r4737355 * r4737356;
double r4737358 = r4737354 - r4737357;
double r4737359 = r4737353 * r4737353;
double r4737360 = r4737356 * r4737356;
double r4737361 = r4737359 + r4737360;
double r4737362 = r4737358 / r4737361;
return r4737362;
}
double f(double a, double b, double c, double d) {
double r4737363 = b;
double r4737364 = c;
double r4737365 = r4737363 * r4737364;
double r4737366 = a;
double r4737367 = d;
double r4737368 = r4737366 * r4737367;
double r4737369 = r4737365 - r4737368;
double r4737370 = r4737364 * r4737364;
double r4737371 = r4737367 * r4737367;
double r4737372 = r4737370 + r4737371;
double r4737373 = r4737369 / r4737372;
double r4737374 = 1.4994875845408422e+304;
bool r4737375 = r4737373 <= r4737374;
double r4737376 = sqrt(r4737372);
double r4737377 = r4737369 / r4737376;
double r4737378 = r4737377 / r4737376;
double r4737379 = r4737363 / r4737376;
double r4737380 = r4737375 ? r4737378 : r4737379;
return r4737380;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.0 |
|---|---|
| Target | 0.4 |
| Herbie | 25.4 |
if (/ (- (* b c) (* a d)) (+ (* c c) (* d d))) < 1.4994875845408422e+304Initial program 13.9
rmApplied add-sqr-sqrt13.9
Applied associate-/r*13.8
if 1.4994875845408422e+304 < (/ (- (* b c) (* a d)) (+ (* c c) (* d d))) Initial program 62.2
rmApplied add-sqr-sqrt62.2
Applied associate-/r*62.2
rmApplied add-sqr-sqrt62.2
Applied sqrt-prod62.2
Taylor expanded around inf 59.9
Final simplification25.4
herbie shell --seed 2019139
(FPCore (a b c d)
:name "Complex division, imag part"
:herbie-target
(if (< (fabs d) (fabs c)) (/ (- b (* a (/ d c))) (+ c (* d (/ d c)))) (/ (+ (- a) (* b (/ c d))) (+ d (* c (/ c d)))))
(/ (- (* b c) (* a d)) (+ (* c c) (* d d))))