\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;c \leq -3.4420726088017006 \cdot 10^{-112} \lor \neg \left(c \leq 2.206658626264936 \cdot 10^{-10}\right):\\
\;\;\;\;\frac{c}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{b}{\sqrt{c \cdot c + d \cdot d}} - d \cdot \frac{a}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;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}}\\
\end{array}(FPCore (a b c d) :precision binary64 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
(FPCore (a b c d)
:precision binary64
(if (or (<= c -3.4420726088017006e-112) (not (<= c 2.206658626264936e-10)))
(-
(* (/ c (sqrt (+ (* c c) (* d d)))) (/ b (sqrt (+ (* c c) (* d d)))))
(* d (/ a (+ (* c c) (* d d)))))
(-
(* c (/ b (+ (* c c) (* d d))))
(* (/ d (sqrt (+ (* c c) (* d d)))) (/ a (sqrt (+ (* c c) (* d d))))))))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 (((c <= -3.4420726088017006e-112) || !(c <= 2.206658626264936e-10))) {
VAR = ((double) (((double) ((c / ((double) sqrt(((double) (((double) (c * c)) + ((double) (d * d))))))) * (b / ((double) sqrt(((double) (((double) (c * c)) + ((double) (d * d))))))))) - ((double) (d * (a / ((double) (((double) (c * c)) + ((double) (d * d)))))))));
} else {
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)))))))))));
}
return VAR;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.0 |
|---|---|
| Target | 0.5 |
| Herbie | 24.4 |
if c < -3.44207260880170059e-112 or 2.206658626264936e-10 < c Initial program 29.3
rmApplied div-sub29.3
Simplified28.3
Simplified27.8
rmApplied add-sqr-sqrt27.8
Applied *-un-lft-identity27.8
Applied times-frac27.7
Applied associate-*r*26.0
Simplified26.0
if -3.44207260880170059e-112 < c < 2.206658626264936e-10Initial program 20.6
rmApplied div-sub20.6
Simplified24.3
Simplified25.3
rmApplied add-sqr-sqrt25.3
Applied *-un-lft-identity25.3
Applied times-frac25.3
Applied associate-*r*21.9
Simplified21.8
Final simplification24.4
herbie shell --seed 2020198
(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))))