\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;c \le -5.24214216730030625 \cdot 10^{138}:\\
\;\;\;\;\frac{-1 \cdot b}{\mathsf{hypot}\left(c, d\right) \cdot 1}\\
\mathbf{elif}\;c \le 5.31450108717881093 \cdot 10^{140}:\\
\;\;\;\;\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{b}{\mathsf{hypot}\left(c, d\right) \cdot 1}\\
\end{array}double f(double a, double b, double c, double d) {
double r117042 = b;
double r117043 = c;
double r117044 = r117042 * r117043;
double r117045 = a;
double r117046 = d;
double r117047 = r117045 * r117046;
double r117048 = r117044 - r117047;
double r117049 = r117043 * r117043;
double r117050 = r117046 * r117046;
double r117051 = r117049 + r117050;
double r117052 = r117048 / r117051;
return r117052;
}
double f(double a, double b, double c, double d) {
double r117053 = c;
double r117054 = -5.242142167300306e+138;
bool r117055 = r117053 <= r117054;
double r117056 = -1.0;
double r117057 = b;
double r117058 = r117056 * r117057;
double r117059 = d;
double r117060 = hypot(r117053, r117059);
double r117061 = 1.0;
double r117062 = r117060 * r117061;
double r117063 = r117058 / r117062;
double r117064 = 5.314501087178811e+140;
bool r117065 = r117053 <= r117064;
double r117066 = r117057 * r117053;
double r117067 = a;
double r117068 = r117067 * r117059;
double r117069 = r117066 - r117068;
double r117070 = r117069 / r117060;
double r117071 = r117070 / r117062;
double r117072 = r117057 / r117062;
double r117073 = r117065 ? r117071 : r117072;
double r117074 = r117055 ? r117063 : r117073;
return r117074;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.1 |
|---|---|
| Target | 0.4 |
| Herbie | 12.9 |
if c < -5.242142167300306e+138Initial program 43.7
rmApplied add-sqr-sqrt43.7
Applied *-un-lft-identity43.7
Applied times-frac43.7
Simplified43.7
Simplified28.3
rmApplied associate-*l/28.3
Simplified28.3
Taylor expanded around -inf 13.9
if -5.242142167300306e+138 < c < 5.314501087178811e+140Initial program 19.1
rmApplied add-sqr-sqrt19.1
Applied *-un-lft-identity19.1
Applied times-frac19.1
Simplified19.1
Simplified12.2
rmApplied associate-*l/12.1
Simplified12.1
if 5.314501087178811e+140 < c Initial program 42.9
rmApplied add-sqr-sqrt42.9
Applied *-un-lft-identity42.9
Applied times-frac42.9
Simplified42.9
Simplified28.6
rmApplied associate-*l/28.5
Simplified28.5
Taylor expanded around inf 15.8
Final simplification12.9
herbie shell --seed 2020100 +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))))