\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;c \le -6.603705426560988 \cdot 10^{+145}:\\
\;\;\;\;\frac{-b}{\mathsf{hypot}\left(d, c\right)}\\
\mathbf{elif}\;c \le 7.75132925369235 \cdot 10^{+139}:\\
\;\;\;\;\frac{\left(b \cdot c - d \cdot a\right) \cdot \frac{1}{\mathsf{hypot}\left(d, c\right)}}{\mathsf{hypot}\left(d, c\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{\mathsf{hypot}\left(d, c\right)}\\
\end{array}double f(double a, double b, double c, double d) {
double r1750462 = b;
double r1750463 = c;
double r1750464 = r1750462 * r1750463;
double r1750465 = a;
double r1750466 = d;
double r1750467 = r1750465 * r1750466;
double r1750468 = r1750464 - r1750467;
double r1750469 = r1750463 * r1750463;
double r1750470 = r1750466 * r1750466;
double r1750471 = r1750469 + r1750470;
double r1750472 = r1750468 / r1750471;
return r1750472;
}
double f(double a, double b, double c, double d) {
double r1750473 = c;
double r1750474 = -6.603705426560988e+145;
bool r1750475 = r1750473 <= r1750474;
double r1750476 = b;
double r1750477 = -r1750476;
double r1750478 = d;
double r1750479 = hypot(r1750478, r1750473);
double r1750480 = r1750477 / r1750479;
double r1750481 = 7.75132925369235e+139;
bool r1750482 = r1750473 <= r1750481;
double r1750483 = r1750476 * r1750473;
double r1750484 = a;
double r1750485 = r1750478 * r1750484;
double r1750486 = r1750483 - r1750485;
double r1750487 = 1.0;
double r1750488 = r1750487 / r1750479;
double r1750489 = r1750486 * r1750488;
double r1750490 = r1750489 / r1750479;
double r1750491 = r1750476 / r1750479;
double r1750492 = r1750482 ? r1750490 : r1750491;
double r1750493 = r1750475 ? r1750480 : r1750492;
return r1750493;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.0 |
|---|---|
| Target | 0.5 |
| Herbie | 13.0 |
if c < -6.603705426560988e+145Initial program 43.7
Simplified43.7
rmApplied add-sqr-sqrt43.7
Applied associate-/r*43.7
rmApplied fma-udef43.7
Applied hypot-def43.7
Taylor expanded around -inf 14.1
Simplified14.1
if -6.603705426560988e+145 < c < 7.75132925369235e+139Initial program 19.0
Simplified19.0
rmApplied add-sqr-sqrt19.0
Applied associate-/r*19.0
rmApplied fma-udef19.0
Applied hypot-def18.9
rmApplied *-un-lft-identity18.9
Applied associate-/r*18.9
Simplified12.3
rmApplied div-inv12.4
if 7.75132925369235e+139 < c Initial program 42.9
Simplified42.9
rmApplied add-sqr-sqrt42.9
Applied associate-/r*42.9
rmApplied fma-udef42.9
Applied hypot-def42.9
Taylor expanded around inf 15.2
Final simplification13.0
herbie shell --seed 2019156 +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))))