\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;d \le 4.2951020985839212 \cdot 10^{83}:\\
\;\;\;\;\frac{\frac{b \cdot c - a \cdot d}{\sqrt{c \cdot c + d \cdot d}}}{\sqrt{c \cdot c + d \cdot d}}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1 \cdot a}{\sqrt{c \cdot c + d \cdot d}}\\
\end{array}double code(double a, double b, double c, double d) {
return (((b * c) - (a * d)) / ((c * c) + (d * d)));
}
double code(double a, double b, double c, double d) {
double VAR;
if ((d <= 4.295102098583921e+83)) {
VAR = ((((b * c) - (a * d)) / sqrt(((c * c) + (d * d)))) / sqrt(((c * c) + (d * d))));
} else {
VAR = ((-1.0 * a) / sqrt(((c * c) + (d * d))));
}
return VAR;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.1 |
|---|---|
| Target | 0.4 |
| Herbie | 26.0 |
if d < 4.295102098583921e+83Initial program 23.2
rmApplied add-sqr-sqrt23.2
Applied associate-/r*23.1
if 4.295102098583921e+83 < d Initial program 38.6
rmApplied add-sqr-sqrt38.6
Applied associate-/r*38.6
Taylor expanded around 0 38.4
Final simplification26.0
herbie shell --seed 2020092
(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))))