\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;d \le 1.5173701027657723 \cdot 10^{98}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right) \cdot 1} \cdot \frac{1}{\frac{\mathsf{hypot}\left(c, d\right)}{b \cdot c - a \cdot d}}\\
\mathbf{else}:\\
\;\;\;\;{\left(\frac{-1 \cdot a}{\mathsf{hypot}\left(c, d\right)}\right)}^{1}\\
\end{array}double f(double a, double b, double c, double d) {
double r76506 = b;
double r76507 = c;
double r76508 = r76506 * r76507;
double r76509 = a;
double r76510 = d;
double r76511 = r76509 * r76510;
double r76512 = r76508 - r76511;
double r76513 = r76507 * r76507;
double r76514 = r76510 * r76510;
double r76515 = r76513 + r76514;
double r76516 = r76512 / r76515;
return r76516;
}
double f(double a, double b, double c, double d) {
double r76517 = d;
double r76518 = 1.5173701027657723e+98;
bool r76519 = r76517 <= r76518;
double r76520 = 1.0;
double r76521 = c;
double r76522 = hypot(r76521, r76517);
double r76523 = r76522 * r76520;
double r76524 = r76520 / r76523;
double r76525 = b;
double r76526 = r76525 * r76521;
double r76527 = a;
double r76528 = r76527 * r76517;
double r76529 = r76526 - r76528;
double r76530 = r76522 / r76529;
double r76531 = r76520 / r76530;
double r76532 = r76524 * r76531;
double r76533 = -1.0;
double r76534 = r76533 * r76527;
double r76535 = r76534 / r76522;
double r76536 = pow(r76535, r76520);
double r76537 = r76519 ? r76532 : r76536;
return r76537;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 25.5 |
|---|---|
| Target | 0.5 |
| Herbie | 14.5 |
if d < 1.5173701027657723e+98Initial program 22.6
rmApplied add-sqr-sqrt22.6
Applied *-un-lft-identity22.6
Applied times-frac22.6
Simplified22.6
Simplified14.0
rmApplied clear-num14.0
if 1.5173701027657723e+98 < d Initial program 39.2
rmApplied add-sqr-sqrt39.2
Applied *-un-lft-identity39.2
Applied times-frac39.2
Simplified39.2
Simplified26.3
rmApplied pow126.3
Applied pow126.3
Applied pow-prod-down26.3
Simplified26.2
Taylor expanded around 0 16.8
Final simplification14.5
herbie shell --seed 2020035 +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))))