\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;d \le -6.5063855279161376 \cdot 10^{152} \lor \neg \left(d \le 2.9116788974845384 \cdot 10^{85}\right):\\
\;\;\;\;\frac{b}{\frac{\mathsf{fma}\left(c, c, d \cdot d\right)}{c}} - \frac{a}{\mathsf{hypot}\left(c, d\right) \cdot \frac{\mathsf{hypot}\left(c, d\right)}{d}}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{\mathsf{hypot}\left(c, d\right) \cdot \frac{\mathsf{hypot}\left(c, d\right)}{c}} - \frac{a}{\frac{\mathsf{fma}\left(c, c, d \cdot d\right)}{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 <= -6.506385527916138e+152) || !(d <= 2.9116788974845384e+85))) {
VAR = ((double) (((double) (b / ((double) (((double) fma(c, c, ((double) (d * d)))) / c)))) - ((double) (a / ((double) (((double) hypot(c, d)) * ((double) (((double) hypot(c, d)) / d))))))));
} else {
VAR = ((double) (((double) (b / ((double) (((double) hypot(c, d)) * ((double) (((double) hypot(c, d)) / c)))))) - ((double) (a / ((double) (((double) fma(c, c, ((double) (d * d)))) / d))))));
}
return VAR;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 27.0 |
|---|---|
| Target | 0.5 |
| Herbie | 8.0 |
if d < -6.506385527916138e+152 or 2.9116788974845384e+85 < d Initial program 42.3
rmApplied div-sub42.3
Simplified42.2
Simplified39.5
rmApplied *-un-lft-identity39.5
Applied add-sqr-sqrt39.5
Applied times-frac39.5
Simplified39.5
Simplified11.9
if -6.506385527916138e+152 < d < 2.9116788974845384e+85Initial program 19.7
rmApplied div-sub19.7
Simplified17.5
Simplified16.4
rmApplied *-un-lft-identity16.4
Applied add-sqr-sqrt16.4
Applied times-frac16.4
Simplified16.4
Simplified6.0
Final simplification8.0
herbie shell --seed 2020123 +o rules:numerics
(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))))