\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;c \le -1.3948486356003643 \cdot 10^{148}:\\
\;\;\;\;\frac{-b}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \le 3.07424528363154847 \cdot 10^{128}:\\
\;\;\;\;\frac{\mathsf{fma}\left(b, c, -d \cdot a\right) \cdot \frac{1}{\mathsf{hypot}\left(c, d\right)}}{\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 r152376 = b;
double r152377 = c;
double r152378 = r152376 * r152377;
double r152379 = a;
double r152380 = d;
double r152381 = r152379 * r152380;
double r152382 = r152378 - r152381;
double r152383 = r152377 * r152377;
double r152384 = r152380 * r152380;
double r152385 = r152383 + r152384;
double r152386 = r152382 / r152385;
return r152386;
}
double f(double a, double b, double c, double d) {
double r152387 = c;
double r152388 = -1.3948486356003643e+148;
bool r152389 = r152387 <= r152388;
double r152390 = b;
double r152391 = -r152390;
double r152392 = d;
double r152393 = hypot(r152387, r152392);
double r152394 = r152391 / r152393;
double r152395 = 3.0742452836315485e+128;
bool r152396 = r152387 <= r152395;
double r152397 = a;
double r152398 = r152392 * r152397;
double r152399 = -r152398;
double r152400 = fma(r152390, r152387, r152399);
double r152401 = 1.0;
double r152402 = r152401 / r152393;
double r152403 = r152400 * r152402;
double r152404 = r152403 / r152393;
double r152405 = r152390 / r152393;
double r152406 = r152396 ? r152404 : r152405;
double r152407 = r152389 ? r152394 : r152406;
return r152407;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
| Original | 26.7 |
|---|---|
| Target | 0.5 |
| Herbie | 13.3 |
if c < -1.3948486356003643e+148Initial program 44.3
rmApplied add-sqr-sqrt44.3
Applied *-un-lft-identity44.3
Applied times-frac44.3
Simplified44.3
Simplified28.4
rmApplied associate-*r/28.4
Simplified28.3
Taylor expanded around -inf 14.7
Simplified14.7
if -1.3948486356003643e+148 < c < 3.0742452836315485e+128Initial program 19.9
rmApplied add-sqr-sqrt19.9
Applied *-un-lft-identity19.9
Applied times-frac19.9
Simplified19.9
Simplified12.7
rmApplied associate-*r/12.6
Simplified12.5
rmApplied div-inv12.6
if 3.0742452836315485e+128 < c Initial program 41.8
rmApplied add-sqr-sqrt41.8
Applied *-un-lft-identity41.8
Applied times-frac41.8
Simplified41.8
Simplified27.2
rmApplied associate-*r/27.2
Simplified27.2
Taylor expanded around inf 15.5
Final simplification13.3
herbie shell --seed 2020042 +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))))