\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;c \le -1.10226154286646485 \cdot 10^{147}:\\
\;\;\;\;\frac{-b}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \le 8.6334403648755915 \cdot 10^{78}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(b, c, -d \cdot a\right)}{\mathsf{hypot}\left(c, d\right)}}{\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 r64794 = b;
double r64795 = c;
double r64796 = r64794 * r64795;
double r64797 = a;
double r64798 = d;
double r64799 = r64797 * r64798;
double r64800 = r64796 - r64799;
double r64801 = r64795 * r64795;
double r64802 = r64798 * r64798;
double r64803 = r64801 + r64802;
double r64804 = r64800 / r64803;
return r64804;
}
double f(double a, double b, double c, double d) {
double r64805 = c;
double r64806 = -1.1022615428664649e+147;
bool r64807 = r64805 <= r64806;
double r64808 = b;
double r64809 = -r64808;
double r64810 = d;
double r64811 = hypot(r64805, r64810);
double r64812 = r64809 / r64811;
double r64813 = 8.633440364875592e+78;
bool r64814 = r64805 <= r64813;
double r64815 = a;
double r64816 = r64810 * r64815;
double r64817 = -r64816;
double r64818 = fma(r64808, r64805, r64817);
double r64819 = r64818 / r64811;
double r64820 = r64819 / r64811;
double r64821 = r64808 / r64811;
double r64822 = r64814 ? r64820 : r64821;
double r64823 = r64807 ? r64812 : r64822;
return r64823;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
| Original | 25.9 |
|---|---|
| Target | 0.4 |
| Herbie | 13.0 |
if c < -1.1022615428664649e+147Initial program 43.9
rmApplied add-sqr-sqrt43.9
Applied *-un-lft-identity43.9
Applied times-frac43.9
Simplified43.9
Simplified28.9
rmApplied *-un-lft-identity28.9
Applied associate-*l*28.9
Simplified28.9
Taylor expanded around -inf 14.1
Simplified14.1
if -1.1022615428664649e+147 < c < 8.633440364875592e+78Initial program 18.4
rmApplied add-sqr-sqrt18.4
Applied *-un-lft-identity18.4
Applied times-frac18.4
Simplified18.4
Simplified11.7
rmApplied *-un-lft-identity11.7
Applied associate-*l*11.7
Simplified11.6
if 8.633440364875592e+78 < c Initial program 38.7
rmApplied add-sqr-sqrt38.7
Applied *-un-lft-identity38.7
Applied times-frac38.7
Simplified38.7
Simplified27.0
rmApplied *-un-lft-identity27.0
Applied associate-*l*27.0
Simplified26.9
Taylor expanded around inf 17.2
Final simplification13.0
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))))