\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;c \le -1.2109434524169916 \cdot 10^{+96}:\\
\;\;\;\;-\frac{b}{\sqrt{c \cdot c + d \cdot d}}\\
\mathbf{elif}\;c \le 5.2422713568197025 \cdot 10^{+36}:\\
\;\;\;\;\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{b}{\sqrt{c \cdot c + d \cdot d}}\\
\end{array}double f(double a, double b, double c, double d) {
double r4760582 = b;
double r4760583 = c;
double r4760584 = r4760582 * r4760583;
double r4760585 = a;
double r4760586 = d;
double r4760587 = r4760585 * r4760586;
double r4760588 = r4760584 - r4760587;
double r4760589 = r4760583 * r4760583;
double r4760590 = r4760586 * r4760586;
double r4760591 = r4760589 + r4760590;
double r4760592 = r4760588 / r4760591;
return r4760592;
}
double f(double a, double b, double c, double d) {
double r4760593 = c;
double r4760594 = -1.2109434524169916e+96;
bool r4760595 = r4760593 <= r4760594;
double r4760596 = b;
double r4760597 = r4760593 * r4760593;
double r4760598 = d;
double r4760599 = r4760598 * r4760598;
double r4760600 = r4760597 + r4760599;
double r4760601 = sqrt(r4760600);
double r4760602 = r4760596 / r4760601;
double r4760603 = -r4760602;
double r4760604 = 5.2422713568197025e+36;
bool r4760605 = r4760593 <= r4760604;
double r4760606 = r4760596 * r4760593;
double r4760607 = a;
double r4760608 = r4760607 * r4760598;
double r4760609 = r4760606 - r4760608;
double r4760610 = r4760609 / r4760601;
double r4760611 = r4760610 / r4760601;
double r4760612 = r4760605 ? r4760611 : r4760602;
double r4760613 = r4760595 ? r4760603 : r4760612;
return r4760613;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.0 |
|---|---|
| Target | 0.5 |
| Herbie | 26.2 |
if c < -1.2109434524169916e+96Initial program 39.0
rmApplied add-sqr-sqrt39.0
Applied associate-/r*38.9
Taylor expanded around -inf 38.2
Simplified38.2
if -1.2109434524169916e+96 < c < 5.2422713568197025e+36Initial program 18.5
rmApplied add-sqr-sqrt18.5
Applied associate-/r*18.4
if 5.2422713568197025e+36 < c Initial program 34.4
rmApplied add-sqr-sqrt34.5
Applied associate-/r*34.4
Taylor expanded around inf 36.1
Final simplification26.2
herbie shell --seed 2019165
(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))))