\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} = -\infty:\\
\;\;\;\;\frac{-1 \cdot b}{\sqrt{c \cdot c + d \cdot d}}\\
\mathbf{elif}\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \le 6.3661068469165699 \cdot 10^{269}:\\
\;\;\;\;\frac{1}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{b \cdot c - a \cdot d}{\sqrt{c \cdot c + d \cdot d}}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{\sqrt{c \cdot c + d \cdot d}}\\
\end{array}double f(double a, double b, double c, double d) {
double r113983 = b;
double r113984 = c;
double r113985 = r113983 * r113984;
double r113986 = a;
double r113987 = d;
double r113988 = r113986 * r113987;
double r113989 = r113985 - r113988;
double r113990 = r113984 * r113984;
double r113991 = r113987 * r113987;
double r113992 = r113990 + r113991;
double r113993 = r113989 / r113992;
return r113993;
}
double f(double a, double b, double c, double d) {
double r113994 = b;
double r113995 = c;
double r113996 = r113994 * r113995;
double r113997 = a;
double r113998 = d;
double r113999 = r113997 * r113998;
double r114000 = r113996 - r113999;
double r114001 = r113995 * r113995;
double r114002 = r113998 * r113998;
double r114003 = r114001 + r114002;
double r114004 = r114000 / r114003;
double r114005 = -inf.0;
bool r114006 = r114004 <= r114005;
double r114007 = -1.0;
double r114008 = r114007 * r113994;
double r114009 = sqrt(r114003);
double r114010 = r114008 / r114009;
double r114011 = 6.36610684691657e+269;
bool r114012 = r114004 <= r114011;
double r114013 = 1.0;
double r114014 = r114013 / r114009;
double r114015 = r114000 / r114009;
double r114016 = r114014 * r114015;
double r114017 = r113994 / r114009;
double r114018 = r114012 ? r114016 : r114017;
double r114019 = r114006 ? r114010 : r114018;
return r114019;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.1 |
|---|---|
| Target | 0.5 |
| Herbie | 25.3 |
if (/ (- (* b c) (* a d)) (+ (* c c) (* d d))) < -inf.0Initial program 64.0
rmApplied add-sqr-sqrt64.0
Applied associate-/r*64.0
Taylor expanded around -inf 51.9
if -inf.0 < (/ (- (* b c) (* a d)) (+ (* c c) (* d d))) < 6.36610684691657e+269Initial program 12.0
rmApplied clear-num12.1
rmApplied *-un-lft-identity12.1
Applied add-sqr-sqrt12.1
Applied times-frac12.1
Applied add-cube-cbrt12.1
Applied times-frac12.1
Simplified12.1
Simplified12.0
if 6.36610684691657e+269 < (/ (- (* b c) (* a d)) (+ (* c c) (* d d))) Initial program 61.5
rmApplied add-sqr-sqrt61.5
Applied associate-/r*61.5
Taylor expanded around inf 59.8
Final simplification25.3
herbie shell --seed 2020018
(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))))