\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;c \le -1.4815058757062313 \cdot 10^{+190}:\\
\;\;\;\;-\frac{b}{\mathsf{hypot}\left(d, c\right)}\\
\mathbf{elif}\;c \le 4.948399038442073 \cdot 10^{+94}:\\
\;\;\;\;\frac{\frac{b \cdot c - d \cdot a}{\mathsf{hypot}\left(d, c\right)}}{\mathsf{hypot}\left(d, c\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{\mathsf{hypot}\left(d, c\right)}\\
\end{array}double f(double a, double b, double c, double d) {
double r3559903 = b;
double r3559904 = c;
double r3559905 = r3559903 * r3559904;
double r3559906 = a;
double r3559907 = d;
double r3559908 = r3559906 * r3559907;
double r3559909 = r3559905 - r3559908;
double r3559910 = r3559904 * r3559904;
double r3559911 = r3559907 * r3559907;
double r3559912 = r3559910 + r3559911;
double r3559913 = r3559909 / r3559912;
return r3559913;
}
double f(double a, double b, double c, double d) {
double r3559914 = c;
double r3559915 = -1.4815058757062313e+190;
bool r3559916 = r3559914 <= r3559915;
double r3559917 = b;
double r3559918 = d;
double r3559919 = hypot(r3559918, r3559914);
double r3559920 = r3559917 / r3559919;
double r3559921 = -r3559920;
double r3559922 = 4.948399038442073e+94;
bool r3559923 = r3559914 <= r3559922;
double r3559924 = r3559917 * r3559914;
double r3559925 = a;
double r3559926 = r3559918 * r3559925;
double r3559927 = r3559924 - r3559926;
double r3559928 = r3559927 / r3559919;
double r3559929 = r3559928 / r3559919;
double r3559930 = r3559923 ? r3559929 : r3559920;
double r3559931 = r3559916 ? r3559921 : r3559930;
return r3559931;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 25.7 |
|---|---|
| Target | 0.4 |
| Herbie | 12.9 |
if c < -1.4815058757062313e+190Initial program 41.5
Simplified41.5
rmApplied add-sqr-sqrt41.5
Applied associate-/r*41.5
rmApplied fma-udef41.5
Applied hypot-def41.5
rmApplied *-un-lft-identity41.5
Applied associate-/r*41.5
Simplified30.3
Taylor expanded around -inf 11.0
Simplified11.0
if -1.4815058757062313e+190 < c < 4.948399038442073e+94Initial program 20.1
Simplified20.1
rmApplied add-sqr-sqrt20.1
Applied associate-/r*20.0
rmApplied fma-udef20.0
Applied hypot-def20.0
rmApplied *-un-lft-identity20.0
Applied associate-/r*20.0
Simplified12.3
if 4.948399038442073e+94 < c Initial program 38.5
Simplified38.5
rmApplied add-sqr-sqrt38.5
Applied associate-/r*38.5
rmApplied fma-udef38.5
Applied hypot-def38.5
Taylor expanded around inf 16.6
Final simplification12.9
herbie shell --seed 2019142 +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))))