\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.04391992940771602 \cdot 10^{279}:\\
\;\;\;\;\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 r96387 = b;
double r96388 = c;
double r96389 = r96387 * r96388;
double r96390 = a;
double r96391 = d;
double r96392 = r96390 * r96391;
double r96393 = r96389 - r96392;
double r96394 = r96388 * r96388;
double r96395 = r96391 * r96391;
double r96396 = r96394 + r96395;
double r96397 = r96393 / r96396;
return r96397;
}
double f(double a, double b, double c, double d) {
double r96398 = b;
double r96399 = c;
double r96400 = r96398 * r96399;
double r96401 = a;
double r96402 = d;
double r96403 = r96401 * r96402;
double r96404 = r96400 - r96403;
double r96405 = r96399 * r96399;
double r96406 = r96402 * r96402;
double r96407 = r96405 + r96406;
double r96408 = r96404 / r96407;
double r96409 = 1.043919929407716e+279;
bool r96410 = r96408 <= r96409;
double r96411 = sqrt(r96407);
double r96412 = r96404 / r96411;
double r96413 = r96412 / r96411;
double r96414 = r96398 / r96411;
double r96415 = r96410 ? r96413 : r96414;
return r96415;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.1 |
|---|---|
| Target | 0.5 |
| Herbie | 25.6 |
if (/ (- (* b c) (* a d)) (+ (* c c) (* d d))) < 1.043919929407716e+279Initial program 14.2
rmApplied add-sqr-sqrt14.2
Applied associate-/r*14.1
if 1.043919929407716e+279 < (/ (- (* b c) (* a d)) (+ (* c c) (* d d))) Initial program 61.9
rmApplied add-sqr-sqrt61.9
Applied associate-/r*61.9
Taylor expanded around inf 60.3
Final simplification25.6
herbie shell --seed 2020065
(FPCore (a b c d)
:name "Complex division, imag part"
:precision binary64
: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))))