\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;d \le -8.29857753110238368 \cdot 10^{124} \lor \neg \left(d \le 7.1886537093075794 \cdot 10^{50}\right):\\
\;\;\;\;\frac{b \cdot c}{c \cdot c + d \cdot d} - \frac{a}{d + \frac{{c}^{2}}{d}}\\
\mathbf{else}:\\
\;\;\;\;b \cdot \frac{c}{c \cdot c + d \cdot d} - \frac{a \cdot d}{c \cdot c + d \cdot d}\\
\end{array}double code(double a, double b, double c, double d) {
return ((double) (((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 (((d <= -8.298577531102384e+124) || !(d <= 7.1886537093075794e+50))) {
VAR = ((double) (((double) (((double) (b * c)) / ((double) (((double) (c * c)) + ((double) (d * d)))))) - ((double) (a / ((double) (d + ((double) (((double) pow(c, 2.0)) / d))))))));
} else {
VAR = ((double) (((double) (b * ((double) (c / ((double) (((double) (c * c)) + ((double) (d * d)))))))) - ((double) (((double) (a * d)) / ((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.6 |
|---|---|
| Target | 0.4 |
| Herbie | 16.6 |
if d < -8.29857753110238368e124 or 7.1886537093075794e50 < d Initial program 38.1
rmApplied div-sub38.1
rmApplied associate-/l*34.8
Taylor expanded around 0 16.5
if -8.29857753110238368e124 < d < 7.1886537093075794e50Initial program 19.1
rmApplied div-sub19.1
rmApplied *-un-lft-identity19.1
Applied times-frac16.7
Simplified16.7
Final simplification16.6
herbie shell --seed 2020149
(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))))