\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;c \le -5.457377104622505852467015767494503842035 \cdot 10^{208}:\\
\;\;\;\;{\left(\frac{-1 \cdot b}{\mathsf{hypot}\left(c, d\right)}\right)}^{1}\\
\mathbf{elif}\;c \le 1.098050593933298912479119802869378133859 \cdot 10^{-16}:\\
\;\;\;\;{\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.368280955057290886281182593174139313509 \cdot 10^{154}:\\
\;\;\;\;\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{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 r98323 = b;
double r98324 = c;
double r98325 = r98323 * r98324;
double r98326 = a;
double r98327 = d;
double r98328 = r98326 * r98327;
double r98329 = r98325 - r98328;
double r98330 = r98324 * r98324;
double r98331 = r98327 * r98327;
double r98332 = r98330 + r98331;
double r98333 = r98329 / r98332;
return r98333;
}
double f(double a, double b, double c, double d) {
double r98334 = c;
double r98335 = -5.457377104622506e+208;
bool r98336 = r98334 <= r98335;
double r98337 = -1.0;
double r98338 = b;
double r98339 = r98337 * r98338;
double r98340 = d;
double r98341 = hypot(r98334, r98340);
double r98342 = r98339 / r98341;
double r98343 = 1.0;
double r98344 = pow(r98342, r98343);
double r98345 = 1.0980505939332989e-16;
bool r98346 = r98334 <= r98345;
double r98347 = r98338 * r98334;
double r98348 = a;
double r98349 = r98348 * r98340;
double r98350 = r98347 - r98349;
double r98351 = r98350 / r98341;
double r98352 = r98351 / r98341;
double r98353 = pow(r98352, r98343);
double r98354 = 1.368280955057291e+154;
bool r98355 = r98334 <= r98354;
double r98356 = r98340 * r98340;
double r98357 = fma(r98334, r98334, r98356);
double r98358 = r98357 / r98334;
double r98359 = r98338 / r98358;
double r98360 = r98357 / r98340;
double r98361 = r98348 / r98360;
double r98362 = r98359 - r98361;
double r98363 = r98338 / r98341;
double r98364 = pow(r98363, r98343);
double r98365 = r98355 ? r98362 : r98364;
double r98366 = r98346 ? r98353 : r98365;
double r98367 = r98336 ? r98344 : r98366;
return r98367;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
| Original | 26.5 |
|---|---|
| Target | 0.5 |
| Herbie | 13.2 |
if c < -5.457377104622506e+208Initial program 42.4
rmApplied add-sqr-sqrt42.4
Applied *-un-lft-identity42.4
Applied times-frac42.4
Simplified42.4
Simplified31.4
rmApplied pow131.4
Applied pow131.4
Applied pow-prod-down31.4
Simplified31.3
Taylor expanded around -inf 10.1
if -5.457377104622506e+208 < c < 1.0980505939332989e-16Initial program 22.0
rmApplied add-sqr-sqrt22.0
Applied *-un-lft-identity22.0
Applied times-frac22.0
Simplified22.0
Simplified13.6
rmApplied pow113.6
Applied pow113.6
Applied pow-prod-down13.6
Simplified13.5
if 1.0980505939332989e-16 < c < 1.368280955057291e+154Initial program 18.9
rmApplied div-sub18.9
Simplified13.3
Simplified12.5
if 1.368280955057291e+154 < c Initial program 45.0
rmApplied add-sqr-sqrt45.0
Applied *-un-lft-identity45.0
Applied times-frac45.0
Simplified45.0
Simplified27.9
rmApplied pow127.9
Applied pow127.9
Applied pow-prod-down27.9
Simplified27.9
Taylor expanded around inf 14.6
Final simplification13.2
herbie shell --seed 2020002 +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))))