\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;c \le 6.443252805869156 \cdot 10^{+104}:\\
\;\;\;\;\frac{\frac{b \cdot c - d \cdot a}{\sqrt{(d \cdot d + \left(c \cdot c\right))_*}}}{\sqrt{(d \cdot d + \left(c \cdot c\right))_*}}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{\sqrt{(d \cdot d + \left(c \cdot c\right))_*}}\\
\end{array}double f(double a, double b, double c, double d) {
double r26858403 = b;
double r26858404 = c;
double r26858405 = r26858403 * r26858404;
double r26858406 = a;
double r26858407 = d;
double r26858408 = r26858406 * r26858407;
double r26858409 = r26858405 - r26858408;
double r26858410 = r26858404 * r26858404;
double r26858411 = r26858407 * r26858407;
double r26858412 = r26858410 + r26858411;
double r26858413 = r26858409 / r26858412;
return r26858413;
}
double f(double a, double b, double c, double d) {
double r26858414 = c;
double r26858415 = 6.443252805869156e+104;
bool r26858416 = r26858414 <= r26858415;
double r26858417 = b;
double r26858418 = r26858417 * r26858414;
double r26858419 = d;
double r26858420 = a;
double r26858421 = r26858419 * r26858420;
double r26858422 = r26858418 - r26858421;
double r26858423 = r26858414 * r26858414;
double r26858424 = fma(r26858419, r26858419, r26858423);
double r26858425 = sqrt(r26858424);
double r26858426 = r26858422 / r26858425;
double r26858427 = r26858426 / r26858425;
double r26858428 = r26858417 / r26858425;
double r26858429 = r26858416 ? r26858427 : r26858428;
return r26858429;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
| Original | 25.6 |
|---|---|
| Target | 0.4 |
| Herbie | 25.5 |
if c < 6.443252805869156e+104Initial program 22.4
Simplified22.4
rmApplied add-sqr-sqrt22.4
Applied *-un-lft-identity22.4
Applied times-frac22.4
rmApplied associate-*l/22.3
if 6.443252805869156e+104 < c Initial program 41.1
Simplified41.1
rmApplied add-sqr-sqrt41.1
Applied associate-/r*41.0
Taylor expanded around inf 40.7
Final simplification25.5
herbie shell --seed 2019104 +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))))