\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;c \le -3.15237965316425658713861194838439775727 \cdot 10^{161}:\\
\;\;\;\;{\left(\frac{-1 \cdot b}{\mathsf{hypot}\left(c, d\right)}\right)}^{1}\\
\mathbf{elif}\;c \le 1.921207477017030655217671855912447948644 \cdot 10^{123}:\\
\;\;\;\;{\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 r137662 = b;
double r137663 = c;
double r137664 = r137662 * r137663;
double r137665 = a;
double r137666 = d;
double r137667 = r137665 * r137666;
double r137668 = r137664 - r137667;
double r137669 = r137663 * r137663;
double r137670 = r137666 * r137666;
double r137671 = r137669 + r137670;
double r137672 = r137668 / r137671;
return r137672;
}
double f(double a, double b, double c, double d) {
double r137673 = c;
double r137674 = -3.1523796531642566e+161;
bool r137675 = r137673 <= r137674;
double r137676 = -1.0;
double r137677 = b;
double r137678 = r137676 * r137677;
double r137679 = d;
double r137680 = hypot(r137673, r137679);
double r137681 = r137678 / r137680;
double r137682 = 1.0;
double r137683 = pow(r137681, r137682);
double r137684 = 1.9212074770170307e+123;
bool r137685 = r137673 <= r137684;
double r137686 = r137677 * r137673;
double r137687 = a;
double r137688 = r137687 * r137679;
double r137689 = r137686 - r137688;
double r137690 = r137689 / r137680;
double r137691 = r137690 / r137680;
double r137692 = pow(r137691, r137682);
double r137693 = r137677 / r137680;
double r137694 = pow(r137693, r137682);
double r137695 = r137685 ? r137692 : r137694;
double r137696 = r137675 ? r137683 : r137695;
return r137696;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.1 |
|---|---|
| Target | 0.5 |
| Herbie | 12.5 |
if c < -3.1523796531642566e+161Initial program 45.4
rmApplied add-sqr-sqrt45.4
Applied *-un-lft-identity45.4
Applied times-frac45.4
Simplified45.4
Simplified29.9
rmApplied pow129.9
Applied pow129.9
Applied pow-prod-down29.9
Simplified29.8
Taylor expanded around -inf 12.9
if -3.1523796531642566e+161 < c < 1.9212074770170307e+123Initial program 19.1
rmApplied add-sqr-sqrt19.1
Applied *-un-lft-identity19.1
Applied times-frac19.1
Simplified19.1
Simplified12.1
rmApplied pow112.1
Applied pow112.1
Applied pow-prod-down12.1
Simplified12.0
if 1.9212074770170307e+123 < c Initial program 41.4
rmApplied add-sqr-sqrt41.4
Applied *-un-lft-identity41.4
Applied times-frac41.4
Simplified41.4
Simplified26.6
rmApplied pow126.6
Applied pow126.6
Applied pow-prod-down26.6
Simplified26.6
Taylor expanded around inf 14.7
Final simplification12.5
herbie shell --seed 2019354 +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))))