\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;c \le -4.012444222764070938318713205906098803793 \cdot 10^{97}:\\
\;\;\;\;\frac{-b}{\mathsf{hypot}\left(d, c\right)}\\
\mathbf{elif}\;c \le 1.124934690533360950950546020938866421399 \cdot 10^{193}:\\
\;\;\;\;\frac{\frac{1}{\frac{\mathsf{hypot}\left(d, c\right)}{b \cdot c - a \cdot d}}}{\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 r8046898 = b;
double r8046899 = c;
double r8046900 = r8046898 * r8046899;
double r8046901 = a;
double r8046902 = d;
double r8046903 = r8046901 * r8046902;
double r8046904 = r8046900 - r8046903;
double r8046905 = r8046899 * r8046899;
double r8046906 = r8046902 * r8046902;
double r8046907 = r8046905 + r8046906;
double r8046908 = r8046904 / r8046907;
return r8046908;
}
double f(double a, double b, double c, double d) {
double r8046909 = c;
double r8046910 = -4.012444222764071e+97;
bool r8046911 = r8046909 <= r8046910;
double r8046912 = b;
double r8046913 = -r8046912;
double r8046914 = d;
double r8046915 = hypot(r8046914, r8046909);
double r8046916 = r8046913 / r8046915;
double r8046917 = 1.124934690533361e+193;
bool r8046918 = r8046909 <= r8046917;
double r8046919 = 1.0;
double r8046920 = r8046912 * r8046909;
double r8046921 = a;
double r8046922 = r8046921 * r8046914;
double r8046923 = r8046920 - r8046922;
double r8046924 = r8046915 / r8046923;
double r8046925 = r8046919 / r8046924;
double r8046926 = r8046925 / r8046915;
double r8046927 = r8046912 / r8046915;
double r8046928 = r8046918 ? r8046926 : r8046927;
double r8046929 = r8046911 ? r8046916 : r8046928;
return r8046929;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.2 |
|---|---|
| Target | 0.4 |
| Herbie | 13.1 |
if c < -4.012444222764071e+97Initial program 39.6
Simplified39.6
rmApplied add-sqr-sqrt39.6
Applied associate-/r*39.6
rmApplied *-un-lft-identity39.6
Applied sqrt-prod39.6
Applied div-inv39.6
Applied times-frac39.6
Simplified39.6
Simplified39.1
rmApplied associate-*r/27.6
Simplified27.6
Taylor expanded around -inf 16.2
Simplified16.2
if -4.012444222764071e+97 < c < 1.124934690533361e+193Initial program 20.8
Simplified20.8
rmApplied add-sqr-sqrt20.8
Applied associate-/r*20.7
rmApplied *-un-lft-identity20.7
Applied sqrt-prod20.7
Applied div-inv20.8
Applied times-frac21.0
Simplified21.0
Simplified20.7
rmApplied associate-*r/12.7
Simplified12.6
rmApplied clear-num12.7
if 1.124934690533361e+193 < c Initial program 41.6
Simplified41.6
rmApplied add-sqr-sqrt41.6
Applied associate-/r*41.6
rmApplied *-un-lft-identity41.6
Applied sqrt-prod41.6
Applied div-inv41.6
Applied times-frac41.6
Simplified41.6
Simplified41.6
rmApplied associate-*r/30.7
Simplified30.6
Taylor expanded around inf 10.3
Final simplification13.1
herbie shell --seed 2019169 +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))))