\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;c \le -2.23527954643198682 \cdot 10^{180}:\\
\;\;\;\;\frac{-1 \cdot b}{\mathsf{hypot}\left(c, d\right) \cdot 1}\\
\mathbf{elif}\;c \le 3.26314722618803973 \cdot 10^{197}:\\
\;\;\;\;\frac{\frac{b \cdot c - a \cdot d}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right) \cdot 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{\mathsf{hypot}\left(c, d\right) \cdot 1}\\
\end{array}double f(double a, double b, double c, double d) {
double r96514 = b;
double r96515 = c;
double r96516 = r96514 * r96515;
double r96517 = a;
double r96518 = d;
double r96519 = r96517 * r96518;
double r96520 = r96516 - r96519;
double r96521 = r96515 * r96515;
double r96522 = r96518 * r96518;
double r96523 = r96521 + r96522;
double r96524 = r96520 / r96523;
return r96524;
}
double f(double a, double b, double c, double d) {
double r96525 = c;
double r96526 = -2.235279546431987e+180;
bool r96527 = r96525 <= r96526;
double r96528 = -1.0;
double r96529 = b;
double r96530 = r96528 * r96529;
double r96531 = d;
double r96532 = hypot(r96525, r96531);
double r96533 = 1.0;
double r96534 = r96532 * r96533;
double r96535 = r96530 / r96534;
double r96536 = 3.26314722618804e+197;
bool r96537 = r96525 <= r96536;
double r96538 = r96529 * r96525;
double r96539 = a;
double r96540 = r96539 * r96531;
double r96541 = r96538 - r96540;
double r96542 = r96541 / r96532;
double r96543 = r96542 / r96534;
double r96544 = r96529 / r96534;
double r96545 = r96537 ? r96543 : r96544;
double r96546 = r96527 ? r96535 : r96545;
return r96546;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 25.8 |
|---|---|
| Target | 0.4 |
| Herbie | 12.6 |
if c < -2.235279546431987e+180Initial program 42.1
rmApplied add-sqr-sqrt42.1
Applied *-un-lft-identity42.1
Applied times-frac42.1
Simplified42.1
Simplified28.1
rmApplied associate-*l/28.0
Simplified28.0
Taylor expanded around -inf 11.1
if -2.235279546431987e+180 < c < 3.26314722618804e+197Initial program 21.2
rmApplied add-sqr-sqrt21.2
Applied *-un-lft-identity21.2
Applied times-frac21.2
Simplified21.2
Simplified13.2
rmApplied associate-*l/13.1
Simplified13.1
if 3.26314722618804e+197 < c Initial program 44.4
rmApplied add-sqr-sqrt44.4
Applied *-un-lft-identity44.4
Applied times-frac44.4
Simplified44.4
Simplified31.2
rmApplied associate-*l/31.2
Simplified31.2
Taylor expanded around inf 10.4
Final simplification12.6
herbie shell --seed 2020089 +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))))