\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;c \le -1.0689057415946615 \cdot 10^{65}:\\
\;\;\;\;{\left(\frac{-1 \cdot b}{\mathsf{hypot}\left(c, d\right)}\right)}^{1}\\
\mathbf{elif}\;c \le 1.5910699936696656 \cdot 10^{174}:\\
\;\;\;\;{\left(\frac{\frac{b \cdot c - a \cdot d}{\mathsf{hypot}\left(c, d\right)}}{\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 r120575 = b;
double r120576 = c;
double r120577 = r120575 * r120576;
double r120578 = a;
double r120579 = d;
double r120580 = r120578 * r120579;
double r120581 = r120577 - r120580;
double r120582 = r120576 * r120576;
double r120583 = r120579 * r120579;
double r120584 = r120582 + r120583;
double r120585 = r120581 / r120584;
return r120585;
}
double f(double a, double b, double c, double d) {
double r120586 = c;
double r120587 = -1.0689057415946615e+65;
bool r120588 = r120586 <= r120587;
double r120589 = -1.0;
double r120590 = b;
double r120591 = r120589 * r120590;
double r120592 = d;
double r120593 = hypot(r120586, r120592);
double r120594 = r120591 / r120593;
double r120595 = 1.0;
double r120596 = pow(r120594, r120595);
double r120597 = 1.5910699936696656e+174;
bool r120598 = r120586 <= r120597;
double r120599 = r120590 * r120586;
double r120600 = a;
double r120601 = r120600 * r120592;
double r120602 = r120599 - r120601;
double r120603 = r120602 / r120593;
double r120604 = r120603 / r120593;
double r120605 = pow(r120604, r120595);
double r120606 = r120590 / r120593;
double r120607 = pow(r120606, r120595);
double r120608 = r120598 ? r120605 : r120607;
double r120609 = r120588 ? r120596 : r120608;
return r120609;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.2 |
|---|---|
| Target | 0.5 |
| Herbie | 13.6 |
if c < -1.0689057415946615e+65Initial program 36.6
rmApplied add-sqr-sqrt36.6
Applied *-un-lft-identity36.6
Applied times-frac36.6
Simplified36.6
Simplified24.6
rmApplied pow124.6
Applied pow124.6
Applied pow-prod-down24.6
Simplified24.5
Taylor expanded around -inf 18.3
if -1.0689057415946615e+65 < c < 1.5910699936696656e+174Initial program 19.4
rmApplied add-sqr-sqrt19.4
Applied *-un-lft-identity19.4
Applied times-frac19.4
Simplified19.4
Simplified12.3
rmApplied pow112.3
Applied pow112.3
Applied pow-prod-down12.3
Simplified12.2
rmApplied clear-num12.3
rmApplied *-un-lft-identity12.3
Applied associate-/r*12.3
Simplified12.2
if 1.5910699936696656e+174 < c Initial program 46.2
rmApplied add-sqr-sqrt46.2
Applied *-un-lft-identity46.2
Applied times-frac46.2
Simplified46.2
Simplified33.7
rmApplied pow133.7
Applied pow133.7
Applied pow-prod-down33.7
Simplified33.7
Taylor expanded around inf 12.8
Final simplification13.6
herbie shell --seed 2020024 +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))))