\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;c \le -4.28661918211577314 \cdot 10^{139}:\\
\;\;\;\;1 \cdot \frac{-1 \cdot b}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \le -1.01190047403502618 \cdot 10^{-272}:\\
\;\;\;\;\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{elif}\;c \le 6.80234349703359644 \cdot 10^{174}:\\
\;\;\;\;1 \cdot \frac{\frac{1}{\frac{\mathsf{hypot}\left(c, d\right)}{b \cdot c - a \cdot d}}}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;1 \cdot \frac{b}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}double f(double a, double b, double c, double d) {
double r120731 = b;
double r120732 = c;
double r120733 = r120731 * r120732;
double r120734 = a;
double r120735 = d;
double r120736 = r120734 * r120735;
double r120737 = r120733 - r120736;
double r120738 = r120732 * r120732;
double r120739 = r120735 * r120735;
double r120740 = r120738 + r120739;
double r120741 = r120737 / r120740;
return r120741;
}
double f(double a, double b, double c, double d) {
double r120742 = c;
double r120743 = -4.286619182115773e+139;
bool r120744 = r120742 <= r120743;
double r120745 = 1.0;
double r120746 = -1.0;
double r120747 = b;
double r120748 = r120746 * r120747;
double r120749 = d;
double r120750 = hypot(r120742, r120749);
double r120751 = r120748 / r120750;
double r120752 = r120745 * r120751;
double r120753 = -1.0119004740350262e-272;
bool r120754 = r120742 <= r120753;
double r120755 = r120749 * r120749;
double r120756 = fma(r120742, r120742, r120755);
double r120757 = r120756 / r120742;
double r120758 = r120747 / r120757;
double r120759 = a;
double r120760 = r120756 / r120749;
double r120761 = r120759 / r120760;
double r120762 = r120758 - r120761;
double r120763 = 6.8023434970335964e+174;
bool r120764 = r120742 <= r120763;
double r120765 = r120747 * r120742;
double r120766 = r120759 * r120749;
double r120767 = r120765 - r120766;
double r120768 = r120750 / r120767;
double r120769 = r120745 / r120768;
double r120770 = r120769 / r120750;
double r120771 = r120745 * r120770;
double r120772 = r120747 / r120750;
double r120773 = r120745 * r120772;
double r120774 = r120764 ? r120771 : r120773;
double r120775 = r120754 ? r120762 : r120774;
double r120776 = r120744 ? r120752 : r120775;
return r120776;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
| Original | 26.1 |
|---|---|
| Target | 0.5 |
| Herbie | 14.0 |
if c < -4.286619182115773e+139Initial program 43.4
rmApplied add-sqr-sqrt43.4
Applied *-un-lft-identity43.4
Applied times-frac43.4
Simplified43.4
Simplified27.9
rmApplied *-un-lft-identity27.9
Applied associate-*l*27.9
Simplified27.8
Taylor expanded around -inf 14.8
if -4.286619182115773e+139 < c < -1.0119004740350262e-272Initial program 19.0
rmApplied div-sub19.0
Simplified17.6
Simplified15.7
if -1.0119004740350262e-272 < c < 6.8023434970335964e+174Initial program 21.0
rmApplied add-sqr-sqrt21.0
Applied *-un-lft-identity21.0
Applied times-frac21.0
Simplified21.0
Simplified12.9
rmApplied *-un-lft-identity12.9
Applied associate-*l*12.9
Simplified12.8
rmApplied clear-num12.9
if 6.8023434970335964e+174 < c Initial program 43.4
rmApplied add-sqr-sqrt43.4
Applied *-un-lft-identity43.4
Applied times-frac43.4
Simplified43.4
Simplified29.1
rmApplied *-un-lft-identity29.1
Applied associate-*l*29.1
Simplified29.0
Taylor expanded around inf 11.8
Final simplification14.0
herbie shell --seed 2020062 +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))))