\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;c \le -3.616216700651156031698756854769588375128 \cdot 10^{205}:\\
\;\;\;\;\frac{-b}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \le 3.891679100942667758376302916106240739893 \cdot 10^{210}:\\
\;\;\;\;\frac{\frac{1}{\frac{\mathsf{hypot}\left(c, d\right)}{\mathsf{fma}\left(c, b, -d \cdot a\right)}}}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}double f(double a, double b, double c, double d) {
double r78037 = b;
double r78038 = c;
double r78039 = r78037 * r78038;
double r78040 = a;
double r78041 = d;
double r78042 = r78040 * r78041;
double r78043 = r78039 - r78042;
double r78044 = r78038 * r78038;
double r78045 = r78041 * r78041;
double r78046 = r78044 + r78045;
double r78047 = r78043 / r78046;
return r78047;
}
double f(double a, double b, double c, double d) {
double r78048 = c;
double r78049 = -3.616216700651156e+205;
bool r78050 = r78048 <= r78049;
double r78051 = b;
double r78052 = -r78051;
double r78053 = d;
double r78054 = hypot(r78048, r78053);
double r78055 = r78052 / r78054;
double r78056 = 3.891679100942668e+210;
bool r78057 = r78048 <= r78056;
double r78058 = 1.0;
double r78059 = a;
double r78060 = r78053 * r78059;
double r78061 = -r78060;
double r78062 = fma(r78048, r78051, r78061);
double r78063 = r78054 / r78062;
double r78064 = r78058 / r78063;
double r78065 = r78064 / r78054;
double r78066 = r78051 / r78054;
double r78067 = r78057 ? r78065 : r78066;
double r78068 = r78050 ? r78055 : r78067;
return r78068;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
| Original | 26.2 |
|---|---|
| Target | 0.5 |
| Herbie | 13.5 |
if c < -3.616216700651156e+205Initial program 42.6
Simplified42.6
rmApplied add-sqr-sqrt42.6
Applied *-un-lft-identity42.6
Applied times-frac42.6
Simplified42.6
Simplified30.9
rmApplied associate-*r/30.8
Simplified30.8
Taylor expanded around -inf 11.2
Simplified11.2
if -3.616216700651156e+205 < c < 3.891679100942668e+210Initial program 23.0
Simplified23.0
rmApplied add-sqr-sqrt23.0
Applied *-un-lft-identity23.0
Applied times-frac23.0
Simplified22.9
Simplified14.0
rmApplied associate-*r/14.0
Simplified13.9
rmApplied clear-num14.0
if 3.891679100942668e+210 < c Initial program 42.4
Simplified42.4
rmApplied add-sqr-sqrt42.4
Applied *-un-lft-identity42.4
Applied times-frac42.4
Simplified42.4
Simplified32.3
rmApplied associate-*r/32.3
Simplified32.3
Taylor expanded around inf 10.5
Final simplification13.5
herbie shell --seed 2019305 +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))))