\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;a \le 2.96629785101132302 \cdot 10^{277}:\\
\;\;\;\;\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 r140339 = b;
double r140340 = c;
double r140341 = r140339 * r140340;
double r140342 = a;
double r140343 = d;
double r140344 = r140342 * r140343;
double r140345 = r140341 - r140344;
double r140346 = r140340 * r140340;
double r140347 = r140343 * r140343;
double r140348 = r140346 + r140347;
double r140349 = r140345 / r140348;
return r140349;
}
double f(double a, double b, double c, double d) {
double r140350 = a;
double r140351 = 2.966297851011323e+277;
bool r140352 = r140350 <= r140351;
double r140353 = b;
double r140354 = c;
double r140355 = r140353 * r140354;
double r140356 = d;
double r140357 = r140350 * r140356;
double r140358 = r140355 - r140357;
double r140359 = r140354 * r140354;
double r140360 = r140356 * r140356;
double r140361 = r140359 + r140360;
double r140362 = sqrt(r140361);
double r140363 = r140358 / r140362;
double r140364 = r140363 / r140362;
double r140365 = -1.0;
double r140366 = r140365 * r140350;
double r140367 = r140366 / r140362;
double r140368 = r140352 ? r140364 : r140367;
return r140368;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.7 |
|---|---|
| Target | 0.6 |
| Herbie | 26.8 |
if a < 2.966297851011323e+277Initial program 26.3
rmApplied add-sqr-sqrt26.3
Applied associate-/r*26.2
if 2.966297851011323e+277 < a Initial program 44.5
rmApplied add-sqr-sqrt44.5
Applied associate-/r*44.5
Taylor expanded around 0 51.6
Final simplification26.8
herbie shell --seed 2020046
(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))))