\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \le 1.221597588228970858235819909623175745754 \cdot 10^{229}:\\
\;\;\;\;\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{-1 \cdot a}{\sqrt{c \cdot c + d \cdot d}}\\
\end{array}double f(double a, double b, double c, double d) {
double r78221 = b;
double r78222 = c;
double r78223 = r78221 * r78222;
double r78224 = a;
double r78225 = d;
double r78226 = r78224 * r78225;
double r78227 = r78223 - r78226;
double r78228 = r78222 * r78222;
double r78229 = r78225 * r78225;
double r78230 = r78228 + r78229;
double r78231 = r78227 / r78230;
return r78231;
}
double f(double a, double b, double c, double d) {
double r78232 = b;
double r78233 = c;
double r78234 = r78232 * r78233;
double r78235 = a;
double r78236 = d;
double r78237 = r78235 * r78236;
double r78238 = r78234 - r78237;
double r78239 = r78233 * r78233;
double r78240 = r78236 * r78236;
double r78241 = r78239 + r78240;
double r78242 = r78238 / r78241;
double r78243 = 1.2215975882289709e+229;
bool r78244 = r78242 <= r78243;
double r78245 = sqrt(r78241);
double r78246 = r78238 / r78245;
double r78247 = r78246 / r78245;
double r78248 = -1.0;
double r78249 = r78248 * r78235;
double r78250 = r78249 / r78245;
double r78251 = r78244 ? r78247 : r78250;
return r78251;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.4 |
|---|---|
| Target | 0.5 |
| Herbie | 26.4 |
if (/ (- (* b c) (* a d)) (+ (* c c) (* d d))) < 1.2215975882289709e+229Initial program 14.8
rmApplied add-sqr-sqrt14.8
Applied associate-/r*14.7
if 1.2215975882289709e+229 < (/ (- (* b c) (* a d)) (+ (* c c) (* d d))) Initial program 59.2
rmApplied add-sqr-sqrt59.2
Applied associate-/r*59.2
Taylor expanded around 0 59.5
Final simplification26.4
herbie shell --seed 2019294
(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))))