\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;c \le 2.1596338989920688 \cdot 10^{+44}:\\
\;\;\;\;\frac{\frac{b \cdot c - a \cdot d}{\sqrt{\mathsf{fma}\left(d, d, c \cdot c\right)}}}{\sqrt{\mathsf{fma}\left(d, d, c \cdot c\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{\sqrt{\mathsf{fma}\left(d, d, c \cdot c\right)}}\\
\end{array}double f(double a, double b, double c, double d) {
double r3977566 = b;
double r3977567 = c;
double r3977568 = r3977566 * r3977567;
double r3977569 = a;
double r3977570 = d;
double r3977571 = r3977569 * r3977570;
double r3977572 = r3977568 - r3977571;
double r3977573 = r3977567 * r3977567;
double r3977574 = r3977570 * r3977570;
double r3977575 = r3977573 + r3977574;
double r3977576 = r3977572 / r3977575;
return r3977576;
}
double f(double a, double b, double c, double d) {
double r3977577 = c;
double r3977578 = 2.1596338989920688e+44;
bool r3977579 = r3977577 <= r3977578;
double r3977580 = b;
double r3977581 = r3977580 * r3977577;
double r3977582 = a;
double r3977583 = d;
double r3977584 = r3977582 * r3977583;
double r3977585 = r3977581 - r3977584;
double r3977586 = r3977577 * r3977577;
double r3977587 = fma(r3977583, r3977583, r3977586);
double r3977588 = sqrt(r3977587);
double r3977589 = r3977585 / r3977588;
double r3977590 = r3977589 / r3977588;
double r3977591 = r3977580 / r3977588;
double r3977592 = r3977579 ? r3977590 : r3977591;
return r3977592;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
| Original | 26.0 |
|---|---|
| Target | 0.4 |
| Herbie | 26.2 |
if c < 2.1596338989920688e+44Initial program 23.3
Simplified23.3
rmApplied add-sqr-sqrt23.3
Applied associate-/r*23.2
Taylor expanded around -inf 23.2
if 2.1596338989920688e+44 < c Initial program 35.6
Simplified35.6
rmApplied add-sqr-sqrt35.6
Applied associate-/r*35.5
Taylor expanded around inf 36.3
Final simplification26.2
herbie shell --seed 2019139 +o rules:numerics
(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))))