\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;d \le 2.013241145516733454875982293839386875987 \cdot 10^{88}:\\
\;\;\;\;\frac{\frac{1}{\frac{\sqrt{c \cdot c + d \cdot d}}{b \cdot c - a \cdot d}}}{\sqrt{c \cdot c + d \cdot d}}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1 \cdot a}{\sqrt{c \cdot c + d \cdot d}}\\
\end{array}double f(double a, double b, double c, double d) {
double r106847 = b;
double r106848 = c;
double r106849 = r106847 * r106848;
double r106850 = a;
double r106851 = d;
double r106852 = r106850 * r106851;
double r106853 = r106849 - r106852;
double r106854 = r106848 * r106848;
double r106855 = r106851 * r106851;
double r106856 = r106854 + r106855;
double r106857 = r106853 / r106856;
return r106857;
}
double f(double a, double b, double c, double d) {
double r106858 = d;
double r106859 = 2.0132411455167335e+88;
bool r106860 = r106858 <= r106859;
double r106861 = 1.0;
double r106862 = c;
double r106863 = r106862 * r106862;
double r106864 = r106858 * r106858;
double r106865 = r106863 + r106864;
double r106866 = sqrt(r106865);
double r106867 = b;
double r106868 = r106867 * r106862;
double r106869 = a;
double r106870 = r106869 * r106858;
double r106871 = r106868 - r106870;
double r106872 = r106866 / r106871;
double r106873 = r106861 / r106872;
double r106874 = r106873 / r106866;
double r106875 = -1.0;
double r106876 = r106875 * r106869;
double r106877 = r106876 / r106866;
double r106878 = r106860 ? r106874 : r106877;
return r106878;
}




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.4 |
if d < 2.0132411455167335e+88Initial program 23.5
rmApplied add-sqr-sqrt23.5
Applied associate-/r*23.4
rmApplied clear-num23.5
if 2.0132411455167335e+88 < d Initial program 39.3
rmApplied add-sqr-sqrt39.3
Applied associate-/r*39.3
Taylor expanded around 0 38.8
Final simplification26.4
herbie shell --seed 2020002
(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))))