\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;c \le -4.28661918211577314 \cdot 10^{139}:\\
\;\;\;\;\frac{-1 \cdot b}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \le -1.01190047403502618 \cdot 10^{-272}:\\
\;\;\;\;\frac{b}{\frac{\mathsf{fma}\left(c, c, d \cdot d\right)}{c}} - \frac{a}{\frac{\mathsf{fma}\left(c, c, d \cdot d\right)}{d}}\\
\mathbf{elif}\;c \le 6.80234349703359644 \cdot 10^{174}:\\
\;\;\;\;\frac{\frac{1}{\frac{\mathsf{hypot}\left(c, d\right)}{b \cdot c - a \cdot d}}}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}double f(double a, double b, double c, double d) {
double r101355 = b;
double r101356 = c;
double r101357 = r101355 * r101356;
double r101358 = a;
double r101359 = d;
double r101360 = r101358 * r101359;
double r101361 = r101357 - r101360;
double r101362 = r101356 * r101356;
double r101363 = r101359 * r101359;
double r101364 = r101362 + r101363;
double r101365 = r101361 / r101364;
return r101365;
}
double f(double a, double b, double c, double d) {
double r101366 = c;
double r101367 = -4.286619182115773e+139;
bool r101368 = r101366 <= r101367;
double r101369 = -1.0;
double r101370 = b;
double r101371 = r101369 * r101370;
double r101372 = d;
double r101373 = hypot(r101366, r101372);
double r101374 = r101371 / r101373;
double r101375 = -1.0119004740350262e-272;
bool r101376 = r101366 <= r101375;
double r101377 = r101372 * r101372;
double r101378 = fma(r101366, r101366, r101377);
double r101379 = r101378 / r101366;
double r101380 = r101370 / r101379;
double r101381 = a;
double r101382 = r101378 / r101372;
double r101383 = r101381 / r101382;
double r101384 = r101380 - r101383;
double r101385 = 6.8023434970335964e+174;
bool r101386 = r101366 <= r101385;
double r101387 = 1.0;
double r101388 = r101370 * r101366;
double r101389 = r101381 * r101372;
double r101390 = r101388 - r101389;
double r101391 = r101373 / r101390;
double r101392 = r101387 / r101391;
double r101393 = r101392 / r101373;
double r101394 = r101370 / r101373;
double r101395 = r101386 ? r101393 : r101394;
double r101396 = r101376 ? r101384 : r101395;
double r101397 = r101368 ? r101374 : r101396;
return r101397;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
| Original | 26.1 |
|---|---|
| Target | 0.5 |
| Herbie | 14.0 |
if c < -4.286619182115773e+139Initial program 43.4
rmApplied add-sqr-sqrt43.4
Applied *-un-lft-identity43.4
Applied times-frac43.4
Simplified43.4
Simplified27.9
rmApplied associate-*r/27.9
Simplified27.8
Taylor expanded around -inf 14.8
if -4.286619182115773e+139 < c < -1.0119004740350262e-272Initial program 19.0
rmApplied div-sub19.0
Simplified17.6
Simplified15.7
if -1.0119004740350262e-272 < c < 6.8023434970335964e+174Initial program 21.0
rmApplied add-sqr-sqrt21.0
Applied *-un-lft-identity21.0
Applied times-frac21.0
Simplified21.0
Simplified12.9
rmApplied associate-*r/12.9
Simplified12.8
rmApplied clear-num12.9
if 6.8023434970335964e+174 < c Initial program 43.4
rmApplied add-sqr-sqrt43.4
Applied *-un-lft-identity43.4
Applied times-frac43.4
Simplified43.4
Simplified29.1
rmApplied associate-*r/29.1
Simplified29.0
Taylor expanded around inf 11.8
Final simplification14.0
herbie shell --seed 2020062 +o rules:numerics
(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))))