\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;d \le -3.629931414478271919204238833322356117894 \cdot 10^{198}:\\
\;\;\;\;\frac{a}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;d \le 1.047334547019426632397659133548071084447 \cdot 10^{85}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(-a, d, c \cdot b\right)}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;-\frac{a}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}double f(double a, double b, double c, double d) {
double r70357 = b;
double r70358 = c;
double r70359 = r70357 * r70358;
double r70360 = a;
double r70361 = d;
double r70362 = r70360 * r70361;
double r70363 = r70359 - r70362;
double r70364 = r70358 * r70358;
double r70365 = r70361 * r70361;
double r70366 = r70364 + r70365;
double r70367 = r70363 / r70366;
return r70367;
}
double f(double a, double b, double c, double d) {
double r70368 = d;
double r70369 = -3.629931414478272e+198;
bool r70370 = r70368 <= r70369;
double r70371 = a;
double r70372 = c;
double r70373 = hypot(r70372, r70368);
double r70374 = r70371 / r70373;
double r70375 = 1.0473345470194266e+85;
bool r70376 = r70368 <= r70375;
double r70377 = -r70371;
double r70378 = b;
double r70379 = r70372 * r70378;
double r70380 = fma(r70377, r70368, r70379);
double r70381 = r70380 / r70373;
double r70382 = r70381 / r70373;
double r70383 = -r70374;
double r70384 = r70376 ? r70382 : r70383;
double r70385 = r70370 ? r70374 : r70384;
return r70385;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
| Original | 25.9 |
|---|---|
| Target | 0.4 |
| Herbie | 13.4 |
if d < -3.629931414478272e+198Initial program 41.5
rmApplied add-sqr-sqrt41.5
Applied *-un-lft-identity41.5
Applied times-frac41.5
Simplified41.5
Simplified31.1
rmApplied associate-*r/31.1
Simplified31.1
Taylor expanded around -inf 10.5
if -3.629931414478272e+198 < d < 1.0473345470194266e+85Initial program 20.6
rmApplied add-sqr-sqrt20.6
Applied *-un-lft-identity20.6
Applied times-frac20.6
Simplified20.6
Simplified12.9
rmApplied associate-*r/12.9
Simplified12.8
rmApplied *-un-lft-identity12.8
if 1.0473345470194266e+85 < d Initial program 37.7
rmApplied add-sqr-sqrt37.7
Applied *-un-lft-identity37.7
Applied times-frac37.7
Simplified37.7
Simplified25.2
rmApplied associate-*r/25.2
Simplified25.1
Taylor expanded around inf 17.2
Simplified17.2
Final simplification13.4
herbie shell --seed 2019195 +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))))