\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;c \le -9.293826114497670869139658346683561592978 \cdot 10^{210}:\\
\;\;\;\;\frac{-1}{\mathsf{hypot}\left(d, c\right)} \cdot b\\
\mathbf{elif}\;c \le 1.15056779942975516580562280806905910555 \cdot 10^{182}:\\
\;\;\;\;\frac{\frac{b \cdot c - d \cdot a}{\mathsf{hypot}\left(d, c\right)}}{\mathsf{hypot}\left(d, c\right)}\\
\mathbf{else}:\\
\;\;\;\;b \cdot \frac{1}{\mathsf{hypot}\left(d, c\right)}\\
\end{array}double f(double a, double b, double c, double d) {
double r5727973 = b;
double r5727974 = c;
double r5727975 = r5727973 * r5727974;
double r5727976 = a;
double r5727977 = d;
double r5727978 = r5727976 * r5727977;
double r5727979 = r5727975 - r5727978;
double r5727980 = r5727974 * r5727974;
double r5727981 = r5727977 * r5727977;
double r5727982 = r5727980 + r5727981;
double r5727983 = r5727979 / r5727982;
return r5727983;
}
double f(double a, double b, double c, double d) {
double r5727984 = c;
double r5727985 = -9.293826114497671e+210;
bool r5727986 = r5727984 <= r5727985;
double r5727987 = -1.0;
double r5727988 = d;
double r5727989 = hypot(r5727988, r5727984);
double r5727990 = r5727987 / r5727989;
double r5727991 = b;
double r5727992 = r5727990 * r5727991;
double r5727993 = 1.1505677994297552e+182;
bool r5727994 = r5727984 <= r5727993;
double r5727995 = r5727991 * r5727984;
double r5727996 = a;
double r5727997 = r5727988 * r5727996;
double r5727998 = r5727995 - r5727997;
double r5727999 = r5727998 / r5727989;
double r5728000 = r5727999 / r5727989;
double r5728001 = 1.0;
double r5728002 = r5728001 / r5727989;
double r5728003 = r5727991 * r5728002;
double r5728004 = r5727994 ? r5728000 : r5728003;
double r5728005 = r5727986 ? r5727992 : r5728004;
return r5728005;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.0 |
|---|---|
| Target | 0.5 |
| Herbie | 13.4 |
if c < -9.293826114497671e+210Initial program 41.6
Simplified41.6
rmApplied clear-num41.6
rmApplied *-un-lft-identity41.6
Applied add-sqr-sqrt41.6
Applied times-frac41.6
Applied add-cube-cbrt41.6
Applied times-frac41.6
Simplified41.6
Simplified29.9
Taylor expanded around -inf 10.2
Simplified10.2
if -9.293826114497671e+210 < c < 1.1505677994297552e+182Initial program 22.3
Simplified22.3
rmApplied clear-num22.4
rmApplied *-un-lft-identity22.4
Applied add-sqr-sqrt22.4
Applied times-frac22.4
Applied add-cube-cbrt22.4
Applied times-frac22.3
Simplified22.3
Simplified14.0
rmApplied associate-*r/14.0
Simplified13.9
if 1.1505677994297552e+182 < c Initial program 42.1
Simplified42.1
rmApplied clear-num42.1
rmApplied *-un-lft-identity42.1
Applied add-sqr-sqrt42.1
Applied times-frac42.1
Applied add-cube-cbrt42.1
Applied times-frac42.1
Simplified42.1
Simplified29.5
Taylor expanded around inf 12.1
Final simplification13.4
herbie shell --seed 2019192 +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))))