\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;c \le -5.9876509466672635 \cdot 10^{162}:\\
\;\;\;\;\frac{-b}{\mathsf{hypot}\left(d, c\right)} \cdot \left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right)\\
\mathbf{elif}\;c \le 2.5019882417216274 \cdot 10^{136}:\\
\;\;\;\;\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \frac{\frac{1}{\frac{\mathsf{hypot}\left(d, c\right)}{\mathsf{fma}\left(b, c, -d \cdot a\right)}}}{\mathsf{hypot}\left(d, c\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \frac{b}{\mathsf{hypot}\left(d, c\right)}\\
\end{array}double f(double a, double b, double c, double d) {
double r124979 = b;
double r124980 = c;
double r124981 = r124979 * r124980;
double r124982 = a;
double r124983 = d;
double r124984 = r124982 * r124983;
double r124985 = r124981 - r124984;
double r124986 = r124980 * r124980;
double r124987 = r124983 * r124983;
double r124988 = r124986 + r124987;
double r124989 = r124985 / r124988;
return r124989;
}
double f(double a, double b, double c, double d) {
double r124990 = c;
double r124991 = -5.9876509466672635e+162;
bool r124992 = r124990 <= r124991;
double r124993 = b;
double r124994 = -r124993;
double r124995 = d;
double r124996 = hypot(r124995, r124990);
double r124997 = r124994 / r124996;
double r124998 = 1.0;
double r124999 = cbrt(r124998);
double r125000 = r124999 * r124999;
double r125001 = r124997 * r125000;
double r125002 = 2.5019882417216274e+136;
bool r125003 = r124990 <= r125002;
double r125004 = a;
double r125005 = r124995 * r125004;
double r125006 = -r125005;
double r125007 = fma(r124993, r124990, r125006);
double r125008 = r124996 / r125007;
double r125009 = r124998 / r125008;
double r125010 = r125009 / r124996;
double r125011 = r125000 * r125010;
double r125012 = r124993 / r124996;
double r125013 = r125000 * r125012;
double r125014 = r125003 ? r125011 : r125013;
double r125015 = r124992 ? r125001 : r125014;
return r125015;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
| Original | 25.7 |
|---|---|
| Target | 0.5 |
| Herbie | 12.5 |
if c < -5.9876509466672635e+162Initial program 43.8
Simplified43.8
rmApplied add-sqr-sqrt43.8
Applied *-un-lft-identity43.8
Applied times-frac43.8
Simplified43.8
Simplified29.5
rmApplied *-un-lft-identity29.5
Applied add-cube-cbrt29.5
Applied times-frac29.5
Applied associate-*l*29.5
Simplified29.5
Taylor expanded around -inf 12.6
Simplified12.6
if -5.9876509466672635e+162 < c < 2.5019882417216274e+136Initial program 19.2
Simplified19.2
rmApplied add-sqr-sqrt19.2
Applied *-un-lft-identity19.2
Applied times-frac19.2
Simplified19.2
Simplified12.1
rmApplied *-un-lft-identity12.1
Applied add-cube-cbrt12.1
Applied times-frac12.1
Applied associate-*l*12.1
Simplified12.0
rmApplied clear-num12.1
if 2.5019882417216274e+136 < c Initial program 42.2
Simplified42.2
rmApplied add-sqr-sqrt42.2
Applied *-un-lft-identity42.2
Applied times-frac42.2
Simplified42.2
Simplified27.3
rmApplied *-un-lft-identity27.3
Applied add-cube-cbrt27.3
Applied times-frac27.3
Applied associate-*l*27.3
Simplified27.3
Taylor expanded around inf 14.6
Final simplification12.5
herbie shell --seed 2020047 +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))))