\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;c \le -1.01458341645274 \cdot 10^{+165}:\\
\;\;\;\;\frac{-b}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \le 2.0408764461888536 \cdot 10^{+156}:\\
\;\;\;\;\frac{\frac{1}{\frac{\mathsf{hypot}\left(c, d\right)}{b \cdot c - a \cdot d}}}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}double f(double a, double b, double c, double d) {
double r27106636 = b;
double r27106637 = c;
double r27106638 = r27106636 * r27106637;
double r27106639 = a;
double r27106640 = d;
double r27106641 = r27106639 * r27106640;
double r27106642 = r27106638 - r27106641;
double r27106643 = r27106637 * r27106637;
double r27106644 = r27106640 * r27106640;
double r27106645 = r27106643 + r27106644;
double r27106646 = r27106642 / r27106645;
return r27106646;
}
double f(double a, double b, double c, double d) {
double r27106647 = c;
double r27106648 = -1.01458341645274e+165;
bool r27106649 = r27106647 <= r27106648;
double r27106650 = b;
double r27106651 = -r27106650;
double r27106652 = d;
double r27106653 = hypot(r27106647, r27106652);
double r27106654 = r27106651 / r27106653;
double r27106655 = 2.0408764461888536e+156;
bool r27106656 = r27106647 <= r27106655;
double r27106657 = 1.0;
double r27106658 = r27106650 * r27106647;
double r27106659 = a;
double r27106660 = r27106659 * r27106652;
double r27106661 = r27106658 - r27106660;
double r27106662 = r27106653 / r27106661;
double r27106663 = r27106657 / r27106662;
double r27106664 = r27106663 / r27106653;
double r27106665 = r27106650 / r27106653;
double r27106666 = r27106656 ? r27106664 : r27106665;
double r27106667 = r27106649 ? r27106654 : r27106666;
return r27106667;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.0 |
|---|---|
| Target | 0.4 |
| Herbie | 12.8 |
if c < -1.01458341645274e+165Initial program 44.3
rmApplied add-sqr-sqrt44.3
Applied associate-/r*44.3
rmApplied fma-neg44.3
rmApplied hypot-def44.3
Taylor expanded around -inf 12.7
Simplified12.7
if -1.01458341645274e+165 < c < 2.0408764461888536e+156Initial program 19.6
rmApplied add-sqr-sqrt19.6
Applied associate-/r*19.5
rmApplied fma-neg19.5
rmApplied hypot-def19.5
rmApplied *-un-lft-identity19.5
Applied associate-/l*19.6
Simplified12.6
if 2.0408764461888536e+156 < c Initial program 44.7
rmApplied add-sqr-sqrt44.7
Applied associate-/r*44.7
rmApplied fma-neg44.7
rmApplied hypot-def44.7
Taylor expanded around inf 14.0
Final simplification12.8
herbie shell --seed 2019128 +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))))