\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;c \le -5.3927648088213951 \cdot 10^{132}:\\
\;\;\;\;{\left(\frac{-1 \cdot b}{\mathsf{hypot}\left(c, d\right)}\right)}^{1}\\
\mathbf{elif}\;c \le -1.2987370292207596 \cdot 10^{-142}:\\
\;\;\;\;\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.1765680479198497 \cdot 10^{-128}:\\
\;\;\;\;{\left(\frac{\frac{b \cdot c - a \cdot d}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\right)}^{1}\\
\mathbf{elif}\;c \le 1.45382927677037052 \cdot 10^{189}:\\
\;\;\;\;{\left(\frac{\frac{c}{\frac{{\left(\sqrt{\mathsf{hypot}\left(c, d\right)}\right)}^{3}}{b}} - \frac{d}{\frac{{\left(\sqrt{\mathsf{hypot}\left(c, d\right)}\right)}^{3}}{a}}}{\sqrt{\mathsf{hypot}\left(c, d\right)}}\right)}^{1}\\
\mathbf{else}:\\
\;\;\;\;{\left(\frac{b}{\mathsf{hypot}\left(c, d\right)}\right)}^{1}\\
\end{array}double f(double a, double b, double c, double d) {
double r136357 = b;
double r136358 = c;
double r136359 = r136357 * r136358;
double r136360 = a;
double r136361 = d;
double r136362 = r136360 * r136361;
double r136363 = r136359 - r136362;
double r136364 = r136358 * r136358;
double r136365 = r136361 * r136361;
double r136366 = r136364 + r136365;
double r136367 = r136363 / r136366;
return r136367;
}
double f(double a, double b, double c, double d) {
double r136368 = c;
double r136369 = -5.392764808821395e+132;
bool r136370 = r136368 <= r136369;
double r136371 = -1.0;
double r136372 = b;
double r136373 = r136371 * r136372;
double r136374 = d;
double r136375 = hypot(r136368, r136374);
double r136376 = r136373 / r136375;
double r136377 = 1.0;
double r136378 = pow(r136376, r136377);
double r136379 = -1.2987370292207596e-142;
bool r136380 = r136368 <= r136379;
double r136381 = r136374 * r136374;
double r136382 = fma(r136368, r136368, r136381);
double r136383 = r136382 / r136368;
double r136384 = r136372 / r136383;
double r136385 = a;
double r136386 = r136382 / r136374;
double r136387 = r136385 / r136386;
double r136388 = r136384 - r136387;
double r136389 = 6.17656804791985e-128;
bool r136390 = r136368 <= r136389;
double r136391 = r136372 * r136368;
double r136392 = r136385 * r136374;
double r136393 = r136391 - r136392;
double r136394 = r136393 / r136375;
double r136395 = r136394 / r136375;
double r136396 = pow(r136395, r136377);
double r136397 = 1.4538292767703705e+189;
bool r136398 = r136368 <= r136397;
double r136399 = sqrt(r136375);
double r136400 = 3.0;
double r136401 = pow(r136399, r136400);
double r136402 = r136401 / r136372;
double r136403 = r136368 / r136402;
double r136404 = r136401 / r136385;
double r136405 = r136374 / r136404;
double r136406 = r136403 - r136405;
double r136407 = r136406 / r136399;
double r136408 = pow(r136407, r136377);
double r136409 = r136372 / r136375;
double r136410 = pow(r136409, r136377);
double r136411 = r136398 ? r136408 : r136410;
double r136412 = r136390 ? r136396 : r136411;
double r136413 = r136380 ? r136388 : r136412;
double r136414 = r136370 ? r136378 : r136413;
return r136414;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
| Original | 26.4 |
|---|---|
| Target | 0.5 |
| Herbie | 12.6 |
if c < -5.392764808821395e+132Initial program 44.3
rmApplied add-sqr-sqrt44.3
Applied *-un-lft-identity44.3
Applied times-frac44.3
Simplified44.3
Simplified29.0
rmApplied pow129.0
Applied pow129.0
Applied pow-prod-down29.0
Simplified28.9
Taylor expanded around -inf 14.7
if -5.392764808821395e+132 < c < -1.2987370292207596e-142Initial program 16.4
rmApplied div-sub16.4
Simplified13.8
Simplified12.1
if -1.2987370292207596e-142 < c < 6.17656804791985e-128Initial program 22.6
rmApplied add-sqr-sqrt22.6
Applied *-un-lft-identity22.6
Applied times-frac22.6
Simplified22.6
Simplified12.4
rmApplied pow112.4
Applied pow112.4
Applied pow-prod-down12.4
Simplified12.2
if 6.17656804791985e-128 < c < 1.4538292767703705e+189Initial program 21.0
rmApplied add-sqr-sqrt21.0
Applied *-un-lft-identity21.0
Applied times-frac21.0
Simplified21.0
Simplified13.2
rmApplied pow113.2
Applied pow113.2
Applied pow-prod-down13.2
Simplified13.1
rmApplied add-sqr-sqrt13.3
Applied associate-/r*13.4
rmApplied div-sub13.4
Applied div-sub13.4
Simplified11.9
Simplified12.2
if 1.4538292767703705e+189 < c Initial program 44.5
rmApplied add-sqr-sqrt44.5
Applied *-un-lft-identity44.5
Applied times-frac44.5
Simplified44.5
Simplified32.0
rmApplied pow132.0
Applied pow132.0
Applied pow-prod-down32.0
Simplified32.0
Taylor expanded around inf 12.6
Final simplification12.6
herbie shell --seed 2020056 +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))))