\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;d \le -1.33199508007579152 \cdot 10^{154}:\\
\;\;\;\;\frac{\frac{1}{\sqrt{\mathsf{hypot}\left(c, d\right)}}}{\frac{\mathsf{hypot}\left(c, d\right)}{\frac{b \cdot c - a \cdot d}{\sqrt{\mathsf{hypot}\left(c, d\right)}}}}\\
\mathbf{elif}\;d \le -0.29009036449311909:\\
\;\;\;\;\frac{b}{\frac{\mathsf{fma}\left(c, c, d \cdot d\right)}{c}} - \frac{a}{\frac{\mathsf{fma}\left(c, c, d \cdot d\right)}{d}}\\
\mathbf{elif}\;d \le 1.37238418162211356 \cdot 10^{-46}:\\
\;\;\;\;\frac{\frac{1}{\frac{\mathsf{hypot}\left(c, d\right)}{b \cdot c - a \cdot d}}}{\mathsf{hypot}\left(c, d\right) \cdot 1}\\
\mathbf{elif}\;d \le 1.24061954906872438 \cdot 10^{154}:\\
\;\;\;\;\frac{b}{\frac{\mathsf{fma}\left(c, c, d \cdot d\right)}{c}} - \frac{a}{\frac{\mathsf{fma}\left(c, c, d \cdot d\right)}{d}}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1 \cdot a}{\mathsf{hypot}\left(c, d\right) \cdot 1}\\
\end{array}double f(double a, double b, double c, double d) {
double r93824 = b;
double r93825 = c;
double r93826 = r93824 * r93825;
double r93827 = a;
double r93828 = d;
double r93829 = r93827 * r93828;
double r93830 = r93826 - r93829;
double r93831 = r93825 * r93825;
double r93832 = r93828 * r93828;
double r93833 = r93831 + r93832;
double r93834 = r93830 / r93833;
return r93834;
}
double f(double a, double b, double c, double d) {
double r93835 = d;
double r93836 = -1.3319950800757915e+154;
bool r93837 = r93835 <= r93836;
double r93838 = 1.0;
double r93839 = c;
double r93840 = hypot(r93839, r93835);
double r93841 = sqrt(r93840);
double r93842 = r93838 / r93841;
double r93843 = b;
double r93844 = r93843 * r93839;
double r93845 = a;
double r93846 = r93845 * r93835;
double r93847 = r93844 - r93846;
double r93848 = r93847 / r93841;
double r93849 = r93840 / r93848;
double r93850 = r93842 / r93849;
double r93851 = -0.2900903644931191;
bool r93852 = r93835 <= r93851;
double r93853 = r93835 * r93835;
double r93854 = fma(r93839, r93839, r93853);
double r93855 = r93854 / r93839;
double r93856 = r93843 / r93855;
double r93857 = r93854 / r93835;
double r93858 = r93845 / r93857;
double r93859 = r93856 - r93858;
double r93860 = 1.3723841816221136e-46;
bool r93861 = r93835 <= r93860;
double r93862 = r93840 / r93847;
double r93863 = r93838 / r93862;
double r93864 = r93840 * r93838;
double r93865 = r93863 / r93864;
double r93866 = 1.2406195490687244e+154;
bool r93867 = r93835 <= r93866;
double r93868 = -1.0;
double r93869 = r93868 * r93845;
double r93870 = r93869 / r93864;
double r93871 = r93867 ? r93859 : r93870;
double r93872 = r93861 ? r93865 : r93871;
double r93873 = r93852 ? r93859 : r93872;
double r93874 = r93837 ? r93850 : r93873;
return r93874;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
| Original | 25.7 |
|---|---|
| Target | 0.5 |
| Herbie | 14.2 |
if d < -1.3319950800757915e+154Initial program 44.3
rmApplied add-sqr-sqrt44.3
Applied *-un-lft-identity44.3
Applied times-frac44.3
Simplified44.3
Simplified28.6
rmApplied associate-*l/28.6
Simplified28.6
rmApplied add-sqr-sqrt28.7
Applied *-un-lft-identity28.7
Applied times-frac28.7
Applied associate-/l*28.7
Simplified28.7
if -1.3319950800757915e+154 < d < -0.2900903644931191 or 1.3723841816221136e-46 < d < 1.2406195490687244e+154Initial program 18.8
rmApplied div-sub18.8
Simplified18.3
Simplified12.9
if -0.2900903644931191 < d < 1.3723841816221136e-46Initial program 18.9
rmApplied add-sqr-sqrt18.9
Applied *-un-lft-identity18.9
Applied times-frac18.9
Simplified18.9
Simplified11.0
rmApplied associate-*l/10.9
Simplified10.9
rmApplied clear-num11.0
if 1.2406195490687244e+154 < d Initial program 45.2
rmApplied add-sqr-sqrt45.2
Applied *-un-lft-identity45.2
Applied times-frac45.2
Simplified45.2
Simplified29.7
rmApplied associate-*l/29.7
Simplified29.7
Taylor expanded around 0 13.4
Final simplification14.2
herbie shell --seed 2020003 +o rules:numerics
(FPCore (a b c d)
:name "Complex division, imag part"
:precision binary64
: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))))