\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;c \le -7.72381449609585197339080432829350912947 \cdot 10^{66}:\\
\;\;\;\;1 \cdot \frac{-1 \cdot b}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \le 3.210000869555314649690325264102980299442 \cdot 10^{117}:\\
\;\;\;\;1 \cdot \frac{\frac{b \cdot c - a \cdot d}{\mathsf{hypot}\left(c, d\right)}}{\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 r85861 = b;
double r85862 = c;
double r85863 = r85861 * r85862;
double r85864 = a;
double r85865 = d;
double r85866 = r85864 * r85865;
double r85867 = r85863 - r85866;
double r85868 = r85862 * r85862;
double r85869 = r85865 * r85865;
double r85870 = r85868 + r85869;
double r85871 = r85867 / r85870;
return r85871;
}
double f(double a, double b, double c, double d) {
double r85872 = c;
double r85873 = -7.723814496095852e+66;
bool r85874 = r85872 <= r85873;
double r85875 = 1.0;
double r85876 = -1.0;
double r85877 = b;
double r85878 = r85876 * r85877;
double r85879 = d;
double r85880 = hypot(r85872, r85879);
double r85881 = r85878 / r85880;
double r85882 = r85875 * r85881;
double r85883 = 3.2100008695553146e+117;
bool r85884 = r85872 <= r85883;
double r85885 = r85877 * r85872;
double r85886 = a;
double r85887 = r85886 * r85879;
double r85888 = r85885 - r85887;
double r85889 = r85888 / r85880;
double r85890 = r85889 / r85880;
double r85891 = r85875 * r85890;
double r85892 = r85877 / r85880;
double r85893 = r85875 * r85892;
double r85894 = r85884 ? r85891 : r85893;
double r85895 = r85874 ? r85882 : r85894;
return r85895;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.5 |
|---|---|
| Target | 0.5 |
| Herbie | 13.9 |
if c < -7.723814496095852e+66Initial program 37.2
rmApplied add-sqr-sqrt37.2
Applied *-un-lft-identity37.2
Applied times-frac37.2
Simplified37.2
Simplified25.4
rmApplied *-un-lft-identity25.4
Applied associate-*l*25.4
Simplified25.4
Taylor expanded around -inf 18.0
if -7.723814496095852e+66 < c < 3.2100008695553146e+117Initial program 19.3
rmApplied add-sqr-sqrt19.3
Applied *-un-lft-identity19.3
Applied times-frac19.3
Simplified19.3
Simplified12.3
rmApplied *-un-lft-identity12.3
Applied associate-*l*12.3
Simplified12.2
if 3.2100008695553146e+117 < c Initial program 40.3
rmApplied add-sqr-sqrt40.3
Applied *-un-lft-identity40.3
Applied times-frac40.3
Simplified40.3
Simplified26.0
rmApplied *-un-lft-identity26.0
Applied associate-*l*26.0
Simplified26.0
Taylor expanded around inf 15.6
Final simplification13.9
herbie shell --seed 2019353 +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))))