\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;d \le 9.136570255790176 \cdot 10^{+58}:\\
\;\;\;\;\frac{\frac{b \cdot c - d \cdot a}{\sqrt{d \cdot d + c \cdot c}}}{\sqrt{d \cdot d + c \cdot c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{-a}{\sqrt{d \cdot d + c \cdot c}}\\
\end{array}double f(double a, double b, double c, double d) {
double r3213993 = b;
double r3213994 = c;
double r3213995 = r3213993 * r3213994;
double r3213996 = a;
double r3213997 = d;
double r3213998 = r3213996 * r3213997;
double r3213999 = r3213995 - r3213998;
double r3214000 = r3213994 * r3213994;
double r3214001 = r3213997 * r3213997;
double r3214002 = r3214000 + r3214001;
double r3214003 = r3213999 / r3214002;
return r3214003;
}
double f(double a, double b, double c, double d) {
double r3214004 = d;
double r3214005 = 9.136570255790176e+58;
bool r3214006 = r3214004 <= r3214005;
double r3214007 = b;
double r3214008 = c;
double r3214009 = r3214007 * r3214008;
double r3214010 = a;
double r3214011 = r3214004 * r3214010;
double r3214012 = r3214009 - r3214011;
double r3214013 = r3214004 * r3214004;
double r3214014 = r3214008 * r3214008;
double r3214015 = r3214013 + r3214014;
double r3214016 = sqrt(r3214015);
double r3214017 = r3214012 / r3214016;
double r3214018 = r3214017 / r3214016;
double r3214019 = -r3214010;
double r3214020 = r3214019 / r3214016;
double r3214021 = r3214006 ? r3214018 : r3214020;
return r3214021;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 25.7 |
|---|---|
| Target | 0.4 |
| Herbie | 25.9 |
if d < 9.136570255790176e+58Initial program 23.1
rmApplied add-sqr-sqrt23.1
Applied associate-/r*23.1
if 9.136570255790176e+58 < d Initial program 35.2
rmApplied add-sqr-sqrt35.2
Applied associate-/r*35.2
Taylor expanded around 0 36.2
Simplified36.2
Final simplification25.9
herbie shell --seed 2019138
(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))))