\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;d \le 7.672387965946080977078573905755541784636 \cdot 10^{87}:\\
\;\;\;\;\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 r7012386 = b;
double r7012387 = c;
double r7012388 = r7012386 * r7012387;
double r7012389 = a;
double r7012390 = d;
double r7012391 = r7012389 * r7012390;
double r7012392 = r7012388 - r7012391;
double r7012393 = r7012387 * r7012387;
double r7012394 = r7012390 * r7012390;
double r7012395 = r7012393 + r7012394;
double r7012396 = r7012392 / r7012395;
return r7012396;
}
double f(double a, double b, double c, double d) {
double r7012397 = d;
double r7012398 = 7.672387965946081e+87;
bool r7012399 = r7012397 <= r7012398;
double r7012400 = b;
double r7012401 = c;
double r7012402 = r7012400 * r7012401;
double r7012403 = a;
double r7012404 = r7012397 * r7012403;
double r7012405 = r7012402 - r7012404;
double r7012406 = r7012397 * r7012397;
double r7012407 = r7012401 * r7012401;
double r7012408 = r7012406 + r7012407;
double r7012409 = sqrt(r7012408);
double r7012410 = r7012405 / r7012409;
double r7012411 = r7012410 / r7012409;
double r7012412 = -r7012403;
double r7012413 = r7012412 / r7012409;
double r7012414 = r7012399 ? r7012411 : r7012413;
return r7012414;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.1 |
|---|---|
| Target | 0.4 |
| Herbie | 26.0 |
if d < 7.672387965946081e+87Initial program 23.1
rmApplied add-sqr-sqrt23.1
Applied associate-/r*23.0
if 7.672387965946081e+87 < d Initial program 38.8
rmApplied add-sqr-sqrt38.8
Applied associate-/r*38.8
Taylor expanded around 0 38.2
Simplified38.2
Final simplification26.0
herbie shell --seed 2019168
(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))))