\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;c \le -8.305623690601149751122925407417973083209 \cdot 10^{163}:\\
\;\;\;\;-\frac{b}{\mathsf{hypot}\left(d, c\right)}\\
\mathbf{elif}\;c \le 2.805404912411875912470168548725953456027 \cdot 10^{84}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\mathsf{hypot}\left(d, c\right)}}{\mathsf{hypot}\left(d, c\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{\mathsf{hypot}\left(d, c\right)}\\
\end{array}double f(double a, double b, double c, double d) {
double r5563859 = b;
double r5563860 = c;
double r5563861 = r5563859 * r5563860;
double r5563862 = a;
double r5563863 = d;
double r5563864 = r5563862 * r5563863;
double r5563865 = r5563861 - r5563864;
double r5563866 = r5563860 * r5563860;
double r5563867 = r5563863 * r5563863;
double r5563868 = r5563866 + r5563867;
double r5563869 = r5563865 / r5563868;
return r5563869;
}
double f(double a, double b, double c, double d) {
double r5563870 = c;
double r5563871 = -8.30562369060115e+163;
bool r5563872 = r5563870 <= r5563871;
double r5563873 = b;
double r5563874 = d;
double r5563875 = hypot(r5563874, r5563870);
double r5563876 = r5563873 / r5563875;
double r5563877 = -r5563876;
double r5563878 = 2.805404912411876e+84;
bool r5563879 = r5563870 <= r5563878;
double r5563880 = a;
double r5563881 = -r5563874;
double r5563882 = r5563880 * r5563881;
double r5563883 = fma(r5563873, r5563870, r5563882);
double r5563884 = r5563883 / r5563875;
double r5563885 = r5563884 / r5563875;
double r5563886 = r5563879 ? r5563885 : r5563876;
double r5563887 = r5563872 ? r5563877 : r5563886;
return r5563887;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
| Original | 26.1 |
|---|---|
| Target | 0.4 |
| Herbie | 13.4 |
if c < -8.30562369060115e+163Initial program 45.0
Simplified45.0
rmApplied add-sqr-sqrt45.0
Applied associate-/r*45.0
rmApplied fma-udef45.0
Applied hypot-def45.0
Taylor expanded around -inf 13.0
Simplified13.0
if -8.30562369060115e+163 < c < 2.805404912411876e+84Initial program 19.4
Simplified19.4
rmApplied add-sqr-sqrt19.5
Applied associate-/r*19.4
rmApplied fma-udef19.4
Applied hypot-def19.3
rmApplied fma-udef19.3
Applied hypot-def12.1
rmApplied fma-neg12.1
if 2.805404912411876e+84 < c Initial program 38.3
Simplified38.3
rmApplied add-sqr-sqrt38.3
Applied associate-/r*38.3
rmApplied fma-udef38.3
Applied hypot-def38.3
Taylor expanded around inf 18.2
Final simplification13.4
herbie shell --seed 2019179 +o rules:numerics
(FPCore (a b c d)
:name "Complex division, imag part"
: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))))