\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.960885555577793652414476012337475353598 \cdot 10^{292}:\\
\;\;\;\;\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 r76323 = b;
double r76324 = c;
double r76325 = r76323 * r76324;
double r76326 = a;
double r76327 = d;
double r76328 = r76326 * r76327;
double r76329 = r76325 - r76328;
double r76330 = r76324 * r76324;
double r76331 = r76327 * r76327;
double r76332 = r76330 + r76331;
double r76333 = r76329 / r76332;
return r76333;
}
double f(double a, double b, double c, double d) {
double r76334 = b;
double r76335 = c;
double r76336 = r76334 * r76335;
double r76337 = a;
double r76338 = d;
double r76339 = r76337 * r76338;
double r76340 = r76336 - r76339;
double r76341 = r76335 * r76335;
double r76342 = r76338 * r76338;
double r76343 = r76341 + r76342;
double r76344 = r76340 / r76343;
double r76345 = 1.9608855555777937e+292;
bool r76346 = r76344 <= r76345;
double r76347 = sqrt(r76343);
double r76348 = r76340 / r76347;
double r76349 = r76348 / r76347;
double r76350 = r76334 / r76347;
double r76351 = r76346 ? r76349 : r76350;
return r76351;
}




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.2 |
if (/ (- (* b c) (* a d)) (+ (* c c) (* d d))) < 1.9608855555777937e+292Initial program 14.3
rmApplied add-sqr-sqrt14.3
Applied associate-/r*14.2
if 1.9608855555777937e+292 < (/ (- (* b c) (* a d)) (+ (* c c) (* d d))) Initial program 62.7
rmApplied add-sqr-sqrt62.7
Applied associate-/r*62.7
Taylor expanded around inf 60.1
Final simplification25.2
herbie shell --seed 2019298
(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))))