\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} \le -6.181451911957164 \cdot 10^{293} \lor \neg \left(\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \le 4.5387220413702261 \cdot 10^{-178}\right):\\
\;\;\;\;c \cdot \frac{b}{c \cdot c + d \cdot d} - \frac{d}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{a}{\sqrt{c \cdot c + d \cdot d}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{b \cdot c - a \cdot d}{\sqrt{c \cdot c + d \cdot d}}\\
\end{array}double code(double a, double b, double c, double d) {
return (((double) (((double) (b * c)) - ((double) (a * d)))) / ((double) (((double) (c * c)) + ((double) (d * d)))));
}
double code(double a, double b, double c, double d) {
double VAR;
if ((((((double) (((double) (b * c)) - ((double) (a * d)))) / ((double) (((double) (c * c)) + ((double) (d * d))))) <= -6.1814519119571635e+293) || !((((double) (((double) (b * c)) - ((double) (a * d)))) / ((double) (((double) (c * c)) + ((double) (d * d))))) <= 4.538722041370226e-178))) {
VAR = ((double) (((double) (c * (b / ((double) (((double) (c * c)) + ((double) (d * d))))))) - ((double) ((d / ((double) sqrt(((double) (((double) (c * c)) + ((double) (d * d))))))) * (a / ((double) sqrt(((double) (((double) (c * c)) + ((double) (d * d)))))))))));
} else {
VAR = ((double) ((1.0 / ((double) sqrt(((double) (((double) (c * c)) + ((double) (d * d))))))) * (((double) (((double) (b * c)) - ((double) (a * d)))) / ((double) sqrt(((double) (((double) (c * c)) + ((double) (d * d)))))))));
}
return VAR;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.5 |
|---|---|
| Target | 0.4 |
| Herbie | 24.0 |
if (/ (- (* b c) (* a d)) (+ (* c c) (* d d))) < -6.181451911957164e293 or 4.5387220413702261e-178 < (/ (- (* b c) (* a d)) (+ (* c c) (* d d))) Initial program 39.2
rmApplied div-sub39.2
Simplified37.4
Simplified34.9
rmApplied add-sqr-sqrt34.9
Applied *-un-lft-identity34.9
Applied times-frac34.9
Applied associate-*r*33.7
Simplified33.7
if -6.181451911957164e293 < (/ (- (* b c) (* a d)) (+ (* c c) (* d d))) < 4.5387220413702261e-178Initial program 15.3
rmApplied add-sqr-sqrt15.3
Applied *-un-lft-identity15.3
Applied times-frac15.3
Final simplification24.0
herbie shell --seed 2020182
(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)))) (/ (+ (neg a) (* b (/ c d))) (+ d (* c (/ c d)))))
(/ (- (* b c) (* a d)) (+ (* c c) (* d d))))