\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;c \le -2.2616143508082277 \cdot 10^{79} \lor \neg \left(c \le 1.03827084215452011 \cdot 10^{-35}\right):\\
\;\;\;\;1 \cdot \left(\frac{\frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}}}{\mathsf{hypot}\left(c, d\right)} - \frac{\frac{a \cdot d}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;1 \cdot \left(\frac{\frac{b \cdot c}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)} - \frac{\frac{a}{1}}{\frac{\mathsf{hypot}\left(c, d\right)}{\frac{d}{\mathsf{hypot}\left(c, d\right)}}}\right)\\
\end{array}double f(double a, double b, double c, double d) {
double r118597 = b;
double r118598 = c;
double r118599 = r118597 * r118598;
double r118600 = a;
double r118601 = d;
double r118602 = r118600 * r118601;
double r118603 = r118599 - r118602;
double r118604 = r118598 * r118598;
double r118605 = r118601 * r118601;
double r118606 = r118604 + r118605;
double r118607 = r118603 / r118606;
return r118607;
}
double f(double a, double b, double c, double d) {
double r118608 = c;
double r118609 = -2.2616143508082277e+79;
bool r118610 = r118608 <= r118609;
double r118611 = 1.0382708421545201e-35;
bool r118612 = r118608 <= r118611;
double r118613 = !r118612;
bool r118614 = r118610 || r118613;
double r118615 = 1.0;
double r118616 = b;
double r118617 = d;
double r118618 = hypot(r118608, r118617);
double r118619 = r118618 / r118608;
double r118620 = r118616 / r118619;
double r118621 = r118620 / r118618;
double r118622 = a;
double r118623 = r118622 * r118617;
double r118624 = r118623 / r118618;
double r118625 = r118624 / r118618;
double r118626 = r118621 - r118625;
double r118627 = r118615 * r118626;
double r118628 = r118616 * r118608;
double r118629 = r118628 / r118618;
double r118630 = r118629 / r118618;
double r118631 = r118622 / r118615;
double r118632 = r118617 / r118618;
double r118633 = r118618 / r118632;
double r118634 = r118631 / r118633;
double r118635 = r118630 - r118634;
double r118636 = r118615 * r118635;
double r118637 = r118614 ? r118627 : r118636;
return r118637;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.5 |
|---|---|
| Target | 0.4 |
| Herbie | 4.8 |
if c < -2.2616143508082277e+79 or 1.0382708421545201e-35 < c Initial program 33.6
rmApplied add-sqr-sqrt33.6
Applied *-un-lft-identity33.6
Applied times-frac33.6
Simplified33.6
Simplified23.3
rmApplied *-un-lft-identity23.3
Applied associate-*l*23.3
Simplified23.2
rmApplied div-sub23.2
Applied div-sub23.2
rmApplied associate-/l*7.8
if -2.2616143508082277e+79 < c < 1.0382708421545201e-35Initial program 19.6
rmApplied add-sqr-sqrt19.6
Applied *-un-lft-identity19.6
Applied times-frac19.6
Simplified19.6
Simplified11.8
rmApplied *-un-lft-identity11.8
Applied associate-*l*11.8
Simplified11.7
rmApplied div-sub11.7
Applied div-sub11.7
rmApplied *-un-lft-identity11.7
Applied times-frac1.7
Applied associate-/l*1.9
Final simplification4.8
herbie shell --seed 2020060 +o rules:numerics
(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))))