\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;a \le 2.96629785101132302 \cdot 10^{277}:\\
\;\;\;\;\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{-a}{\sqrt{c \cdot c + d \cdot d}}\\
\end{array}double f(double a, double b, double c, double d) {
double r132382 = b;
double r132383 = c;
double r132384 = r132382 * r132383;
double r132385 = a;
double r132386 = d;
double r132387 = r132385 * r132386;
double r132388 = r132384 - r132387;
double r132389 = r132383 * r132383;
double r132390 = r132386 * r132386;
double r132391 = r132389 + r132390;
double r132392 = r132388 / r132391;
return r132392;
}
double f(double a, double b, double c, double d) {
double r132393 = a;
double r132394 = 2.966297851011323e+277;
bool r132395 = r132393 <= r132394;
double r132396 = b;
double r132397 = c;
double r132398 = r132396 * r132397;
double r132399 = d;
double r132400 = r132393 * r132399;
double r132401 = r132398 - r132400;
double r132402 = r132397 * r132397;
double r132403 = r132399 * r132399;
double r132404 = r132402 + r132403;
double r132405 = sqrt(r132404);
double r132406 = r132401 / r132405;
double r132407 = r132406 / r132405;
double r132408 = -r132393;
double r132409 = r132408 / r132405;
double r132410 = r132395 ? r132407 : r132409;
return r132410;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.7 |
|---|---|
| Target | 0.6 |
| Herbie | 26.8 |
if a < 2.966297851011323e+277Initial program 26.3
rmApplied add-sqr-sqrt26.3
Applied associate-/r*26.2
if 2.966297851011323e+277 < a Initial program 44.5
rmApplied add-sqr-sqrt44.5
Applied associate-/r*44.5
Taylor expanded around 0 51.6
Simplified51.6
Final simplification26.8
herbie shell --seed 2020046
(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))))