\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;d \le 7.1986768583136221 \cdot 10^{111}:\\
\;\;\;\;\frac{\frac{b \cdot c - a \cdot d}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right) \cdot 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1 \cdot a}{\mathsf{hypot}\left(c, d\right) \cdot 1}\\
\end{array}double f(double a, double b, double c, double d) {
double r93080 = b;
double r93081 = c;
double r93082 = r93080 * r93081;
double r93083 = a;
double r93084 = d;
double r93085 = r93083 * r93084;
double r93086 = r93082 - r93085;
double r93087 = r93081 * r93081;
double r93088 = r93084 * r93084;
double r93089 = r93087 + r93088;
double r93090 = r93086 / r93089;
return r93090;
}
double f(double a, double b, double c, double d) {
double r93091 = d;
double r93092 = 7.198676858313622e+111;
bool r93093 = r93091 <= r93092;
double r93094 = b;
double r93095 = c;
double r93096 = r93094 * r93095;
double r93097 = a;
double r93098 = r93097 * r93091;
double r93099 = r93096 - r93098;
double r93100 = hypot(r93095, r93091);
double r93101 = r93099 / r93100;
double r93102 = 1.0;
double r93103 = r93100 * r93102;
double r93104 = r93101 / r93103;
double r93105 = -1.0;
double r93106 = r93105 * r93097;
double r93107 = r93106 / r93103;
double r93108 = r93093 ? r93104 : r93107;
return r93108;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.0 |
|---|---|
| Target | 0.5 |
| Herbie | 14.6 |
if d < 7.198676858313622e+111Initial program 23.1
rmApplied add-sqr-sqrt23.1
Applied *-un-lft-identity23.1
Applied times-frac23.1
Simplified23.1
Simplified14.6
rmApplied associate-*l/14.5
Simplified14.5
if 7.198676858313622e+111 < d Initial program 40.7
rmApplied add-sqr-sqrt40.7
Applied *-un-lft-identity40.7
Applied times-frac40.7
Simplified40.7
Simplified26.9
rmApplied associate-*l/26.8
Simplified26.8
Taylor expanded around 0 15.4
Final simplification14.6
herbie shell --seed 2020027 +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))))