\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;c \le -1.4037038847053747 \cdot 10^{+154}:\\
\;\;\;\;\frac{-b}{\mathsf{hypot}\left(d, c\right)}\\
\mathbf{elif}\;c \le 1.8584161242035747 \cdot 10^{+93}:\\
\;\;\;\;\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 r2964086 = b;
double r2964087 = c;
double r2964088 = r2964086 * r2964087;
double r2964089 = a;
double r2964090 = d;
double r2964091 = r2964089 * r2964090;
double r2964092 = r2964088 - r2964091;
double r2964093 = r2964087 * r2964087;
double r2964094 = r2964090 * r2964090;
double r2964095 = r2964093 + r2964094;
double r2964096 = r2964092 / r2964095;
return r2964096;
}
double f(double a, double b, double c, double d) {
double r2964097 = c;
double r2964098 = -1.4037038847053747e+154;
bool r2964099 = r2964097 <= r2964098;
double r2964100 = b;
double r2964101 = -r2964100;
double r2964102 = d;
double r2964103 = hypot(r2964102, r2964097);
double r2964104 = r2964101 / r2964103;
double r2964105 = 1.8584161242035747e+93;
bool r2964106 = r2964097 <= r2964105;
double r2964107 = 1.0;
double r2964108 = r2964100 * r2964097;
double r2964109 = a;
double r2964110 = r2964109 * r2964102;
double r2964111 = r2964108 - r2964110;
double r2964112 = r2964103 / r2964111;
double r2964113 = r2964107 / r2964112;
double r2964114 = r2964113 / r2964103;
double r2964115 = r2964100 / r2964103;
double r2964116 = r2964106 ? r2964114 : r2964115;
double r2964117 = r2964099 ? r2964104 : r2964116;
return r2964117;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 25.8 |
|---|---|
| Target | 0.4 |
| Herbie | 12.8 |
if c < -1.4037038847053747e+154Initial program 43.9
Simplified43.9
rmApplied add-sqr-sqrt43.9
Applied associate-/r*43.9
rmApplied fma-udef43.9
Applied hypot-def43.9
rmApplied fma-udef43.9
Applied hypot-def27.1
Taylor expanded around -inf 13.2
Simplified13.2
if -1.4037038847053747e+154 < c < 1.8584161242035747e+93Initial program 18.9
Simplified18.9
rmApplied add-sqr-sqrt18.9
Applied associate-/r*18.8
rmApplied fma-udef18.8
Applied hypot-def18.8
rmApplied fma-udef18.8
Applied hypot-def11.7
rmApplied *-un-lft-identity11.7
Applied associate-/l*11.8
if 1.8584161242035747e+93 < c Initial program 37.5
Simplified37.5
rmApplied add-sqr-sqrt37.5
Applied associate-/r*37.5
rmApplied fma-udef37.5
Applied hypot-def37.5
rmApplied fma-udef37.5
Applied hypot-def24.3
Taylor expanded around inf 15.9
Final simplification12.8
herbie shell --seed 2019151 +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))))