\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;d \le 3.315223608026935 \cdot 10^{+87}:\\
\;\;\;\;\frac{b \cdot c - a \cdot d}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{1}{\mathsf{hypot}\left(d, c\right)}\\
\mathbf{elif}\;d \le 1.263326239685677 \cdot 10^{+154}:\\
\;\;\;\;\frac{-a}{\sqrt{\mathsf{fma}\left(d, d, \left(c \cdot c\right)\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot c - a \cdot d}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{1}{\mathsf{hypot}\left(d, c\right)}\\
\end{array}double f(double a, double b, double c, double d) {
double r2562172 = b;
double r2562173 = c;
double r2562174 = r2562172 * r2562173;
double r2562175 = a;
double r2562176 = d;
double r2562177 = r2562175 * r2562176;
double r2562178 = r2562174 - r2562177;
double r2562179 = r2562173 * r2562173;
double r2562180 = r2562176 * r2562176;
double r2562181 = r2562179 + r2562180;
double r2562182 = r2562178 / r2562181;
return r2562182;
}
double f(double a, double b, double c, double d) {
double r2562183 = d;
double r2562184 = 3.315223608026935e+87;
bool r2562185 = r2562183 <= r2562184;
double r2562186 = b;
double r2562187 = c;
double r2562188 = r2562186 * r2562187;
double r2562189 = a;
double r2562190 = r2562189 * r2562183;
double r2562191 = r2562188 - r2562190;
double r2562192 = hypot(r2562183, r2562187);
double r2562193 = r2562191 / r2562192;
double r2562194 = 1.0;
double r2562195 = r2562194 / r2562192;
double r2562196 = r2562193 * r2562195;
double r2562197 = 1.263326239685677e+154;
bool r2562198 = r2562183 <= r2562197;
double r2562199 = -r2562189;
double r2562200 = r2562187 * r2562187;
double r2562201 = fma(r2562183, r2562183, r2562200);
double r2562202 = sqrt(r2562201);
double r2562203 = r2562199 / r2562202;
double r2562204 = r2562198 ? r2562203 : r2562196;
double r2562205 = r2562185 ? r2562196 : r2562204;
return r2562205;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
| Original | 25.4 |
|---|---|
| Target | 0.5 |
| Herbie | 16.5 |
if d < 3.315223608026935e+87 or 1.263326239685677e+154 < d Initial program 25.6
Simplified25.6
rmApplied clear-num25.7
rmApplied *-un-lft-identity25.7
Applied add-sqr-sqrt25.7
Applied times-frac25.7
Applied add-cube-cbrt25.7
Applied times-frac25.6
Simplified25.6
Simplified16.2
if 3.315223608026935e+87 < d < 1.263326239685677e+154Initial program 22.5
Simplified22.5
rmApplied add-sqr-sqrt22.5
Applied associate-/r*22.4
rmApplied div-inv22.5
Taylor expanded around 0 21.4
Simplified21.4
Final simplification16.5
herbie shell --seed 2019132 +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))))