\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;c \le -7.846283352613039 \cdot 10^{+90}:\\
\;\;\;\;-\frac{b}{\sqrt{c \cdot c + d \cdot d}}\\
\mathbf{elif}\;c \le 5.2422713568197025 \cdot 10^{+36}:\\
\;\;\;\;\frac{\frac{b \cdot c - a \cdot d}{\sqrt{c \cdot c + d \cdot d}}}{\sqrt{c \cdot c + d \cdot d}}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{\sqrt{c \cdot c + d \cdot d}}\\
\end{array}double f(double a, double b, double c, double d) {
double r5984230 = b;
double r5984231 = c;
double r5984232 = r5984230 * r5984231;
double r5984233 = a;
double r5984234 = d;
double r5984235 = r5984233 * r5984234;
double r5984236 = r5984232 - r5984235;
double r5984237 = r5984231 * r5984231;
double r5984238 = r5984234 * r5984234;
double r5984239 = r5984237 + r5984238;
double r5984240 = r5984236 / r5984239;
return r5984240;
}
double f(double a, double b, double c, double d) {
double r5984241 = c;
double r5984242 = -7.846283352613039e+90;
bool r5984243 = r5984241 <= r5984242;
double r5984244 = b;
double r5984245 = r5984241 * r5984241;
double r5984246 = d;
double r5984247 = r5984246 * r5984246;
double r5984248 = r5984245 + r5984247;
double r5984249 = sqrt(r5984248);
double r5984250 = r5984244 / r5984249;
double r5984251 = -r5984250;
double r5984252 = 5.2422713568197025e+36;
bool r5984253 = r5984241 <= r5984252;
double r5984254 = r5984244 * r5984241;
double r5984255 = a;
double r5984256 = r5984255 * r5984246;
double r5984257 = r5984254 - r5984256;
double r5984258 = r5984257 / r5984249;
double r5984259 = r5984258 / r5984249;
double r5984260 = r5984253 ? r5984259 : r5984250;
double r5984261 = r5984243 ? r5984251 : r5984260;
return r5984261;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.5 |
|---|---|
| Target | 0.5 |
| Herbie | 26.5 |
if c < -7.846283352613039e+90Initial program 39.2
rmApplied add-sqr-sqrt39.2
Applied associate-/r*39.2
Taylor expanded around -inf 38.1
Simplified38.1
if -7.846283352613039e+90 < c < 5.2422713568197025e+36Initial program 18.9
rmApplied add-sqr-sqrt18.9
Applied associate-/r*18.8
if 5.2422713568197025e+36 < c Initial program 35.0
rmApplied add-sqr-sqrt35.0
Applied associate-/r*35.0
Taylor expanded around inf 36.1
Final simplification26.5
herbie shell --seed 2019165
(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))))