\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;c \le 6.467777198430207 \cdot 10^{+42}:\\
\;\;\;\;\frac{\frac{b \cdot c - a \cdot d}{\sqrt{d \cdot d + c \cdot c}}}{\sqrt{d \cdot d + c \cdot c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{\sqrt{d \cdot d + c \cdot c}}\\
\end{array}double f(double a, double b, double c, double d) {
double r45917734 = b;
double r45917735 = c;
double r45917736 = r45917734 * r45917735;
double r45917737 = a;
double r45917738 = d;
double r45917739 = r45917737 * r45917738;
double r45917740 = r45917736 - r45917739;
double r45917741 = r45917735 * r45917735;
double r45917742 = r45917738 * r45917738;
double r45917743 = r45917741 + r45917742;
double r45917744 = r45917740 / r45917743;
return r45917744;
}
double f(double a, double b, double c, double d) {
double r45917745 = c;
double r45917746 = 6.467777198430207e+42;
bool r45917747 = r45917745 <= r45917746;
double r45917748 = b;
double r45917749 = r45917748 * r45917745;
double r45917750 = a;
double r45917751 = d;
double r45917752 = r45917750 * r45917751;
double r45917753 = r45917749 - r45917752;
double r45917754 = r45917751 * r45917751;
double r45917755 = r45917745 * r45917745;
double r45917756 = r45917754 + r45917755;
double r45917757 = sqrt(r45917756);
double r45917758 = r45917753 / r45917757;
double r45917759 = r45917758 / r45917757;
double r45917760 = r45917748 / r45917757;
double r45917761 = r45917747 ? r45917759 : r45917760;
return r45917761;
}




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.5 |
if c < 6.467777198430207e+42Initial program 23.7
rmApplied add-sqr-sqrt23.7
Applied associate-/r*23.7
if 6.467777198430207e+42 < c Initial program 34.3
rmApplied add-sqr-sqrt34.3
Applied associate-/r*34.3
rmApplied div-inv34.3
Taylor expanded around inf 35.8
Final simplification26.5
herbie shell --seed 2019124
(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))))