\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;d \le 4.45466791069368503819326346032185071724 \cdot 10^{108}:\\
\;\;\;\;\frac{\left(b \cdot c - a \cdot d\right) \cdot \frac{1}{\sqrt{c \cdot c + d \cdot d}}}{\sqrt{c \cdot c + d \cdot d}}\\
\mathbf{elif}\;d \le 4.152810026092194573941460896261674354973 \cdot 10^{143}:\\
\;\;\;\;\frac{-1 \cdot a}{\sqrt{c \cdot c + d \cdot d}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{b \cdot c - a \cdot d}{\sqrt{c \cdot c + d \cdot d}}}{\left|\sqrt[3]{c \cdot c + d \cdot d}\right| \cdot \sqrt{\sqrt[3]{c \cdot c + d \cdot d}}}\\
\end{array}double f(double a, double b, double c, double d) {
double r91485 = b;
double r91486 = c;
double r91487 = r91485 * r91486;
double r91488 = a;
double r91489 = d;
double r91490 = r91488 * r91489;
double r91491 = r91487 - r91490;
double r91492 = r91486 * r91486;
double r91493 = r91489 * r91489;
double r91494 = r91492 + r91493;
double r91495 = r91491 / r91494;
return r91495;
}
double f(double a, double b, double c, double d) {
double r91496 = d;
double r91497 = 4.454667910693685e+108;
bool r91498 = r91496 <= r91497;
double r91499 = b;
double r91500 = c;
double r91501 = r91499 * r91500;
double r91502 = a;
double r91503 = r91502 * r91496;
double r91504 = r91501 - r91503;
double r91505 = 1.0;
double r91506 = r91500 * r91500;
double r91507 = r91496 * r91496;
double r91508 = r91506 + r91507;
double r91509 = sqrt(r91508);
double r91510 = r91505 / r91509;
double r91511 = r91504 * r91510;
double r91512 = r91511 / r91509;
double r91513 = 4.152810026092195e+143;
bool r91514 = r91496 <= r91513;
double r91515 = -1.0;
double r91516 = r91515 * r91502;
double r91517 = r91516 / r91509;
double r91518 = r91504 / r91509;
double r91519 = cbrt(r91508);
double r91520 = fabs(r91519);
double r91521 = sqrt(r91519);
double r91522 = r91520 * r91521;
double r91523 = r91518 / r91522;
double r91524 = r91514 ? r91517 : r91523;
double r91525 = r91498 ? r91512 : r91524;
return r91525;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.2 |
|---|---|
| Target | 0.5 |
| Herbie | 26.2 |
if d < 4.454667910693685e+108Initial program 23.2
rmApplied add-sqr-sqrt23.2
Applied associate-/r*23.1
rmApplied div-inv23.2
if 4.454667910693685e+108 < d < 4.152810026092195e+143Initial program 23.6
rmApplied add-sqr-sqrt23.6
Applied associate-/r*23.5
Taylor expanded around 0 26.2
if 4.152810026092195e+143 < d Initial program 43.8
rmApplied add-sqr-sqrt43.8
Applied associate-/r*43.8
rmApplied add-cube-cbrt43.8
Applied sqrt-prod43.8
Simplified43.8
Final simplification26.2
herbie shell --seed 2019308
(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))))