\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;c \le -1.8129434842371625 \cdot 10^{150}:\\
\;\;\;\;1 \cdot \frac{-1 \cdot b}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \le -4.4547050749214279 \cdot 10^{-58}:\\
\;\;\;\;\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}\;c \le 1.6620599063431798 \cdot 10^{156}:\\
\;\;\;\;1 \cdot \frac{\frac{b \cdot c - a \cdot d}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;1 \cdot \frac{b}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}double f(double a, double b, double c, double d) {
double r175906 = b;
double r175907 = c;
double r175908 = r175906 * r175907;
double r175909 = a;
double r175910 = d;
double r175911 = r175909 * r175910;
double r175912 = r175908 - r175911;
double r175913 = r175907 * r175907;
double r175914 = r175910 * r175910;
double r175915 = r175913 + r175914;
double r175916 = r175912 / r175915;
return r175916;
}
double f(double a, double b, double c, double d) {
double r175917 = c;
double r175918 = -1.8129434842371625e+150;
bool r175919 = r175917 <= r175918;
double r175920 = 1.0;
double r175921 = -1.0;
double r175922 = b;
double r175923 = r175921 * r175922;
double r175924 = d;
double r175925 = hypot(r175917, r175924);
double r175926 = r175923 / r175925;
double r175927 = r175920 * r175926;
double r175928 = -4.454705074921428e-58;
bool r175929 = r175917 <= r175928;
double r175930 = r175924 * r175924;
double r175931 = fma(r175917, r175917, r175930);
double r175932 = r175931 / r175917;
double r175933 = r175922 / r175932;
double r175934 = a;
double r175935 = r175931 / r175924;
double r175936 = r175934 / r175935;
double r175937 = r175933 - r175936;
double r175938 = 1.6620599063431798e+156;
bool r175939 = r175917 <= r175938;
double r175940 = r175922 * r175917;
double r175941 = r175934 * r175924;
double r175942 = r175940 - r175941;
double r175943 = r175942 / r175925;
double r175944 = r175943 / r175925;
double r175945 = r175920 * r175944;
double r175946 = r175922 / r175925;
double r175947 = r175920 * r175946;
double r175948 = r175939 ? r175945 : r175947;
double r175949 = r175929 ? r175937 : r175948;
double r175950 = r175919 ? r175927 : r175949;
return r175950;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
| Original | 26.2 |
|---|---|
| Target | 0.5 |
| Herbie | 12.7 |
if c < -1.8129434842371625e+150Initial program 45.1
rmApplied add-sqr-sqrt45.1
Applied *-un-lft-identity45.1
Applied times-frac45.1
Simplified45.1
Simplified29.3
rmApplied *-un-lft-identity29.3
Applied associate-*l*29.3
Simplified29.2
Taylor expanded around -inf 14.2
if -1.8129434842371625e+150 < c < -4.454705074921428e-58Initial program 18.5
rmApplied div-sub18.5
Simplified14.0
Simplified12.1
if -4.454705074921428e-58 < c < 1.6620599063431798e+156Initial program 19.8
rmApplied add-sqr-sqrt19.8
Applied *-un-lft-identity19.8
Applied times-frac19.8
Simplified19.8
Simplified12.8
rmApplied *-un-lft-identity12.8
Applied associate-*l*12.8
Simplified12.7
if 1.6620599063431798e+156 < c Initial program 45.5
rmApplied add-sqr-sqrt45.5
Applied *-un-lft-identity45.5
Applied times-frac45.5
Simplified45.5
Simplified29.4
rmApplied *-un-lft-identity29.4
Applied associate-*l*29.4
Simplified29.3
Taylor expanded around inf 11.7
Final simplification12.7
herbie shell --seed 2020033 +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))))