\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} = -\infty:\\
\;\;\;\;\frac{b}{\sqrt{c \cdot c + d \cdot d}}\\
\mathbf{elif}\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \le 1.40075589692360536 \cdot 10^{294}:\\
\;\;\;\;\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{-a}{\sqrt{c \cdot c + d \cdot d}}\\
\end{array}double f(double a, double b, double c, double d) {
double r101246 = b;
double r101247 = c;
double r101248 = r101246 * r101247;
double r101249 = a;
double r101250 = d;
double r101251 = r101249 * r101250;
double r101252 = r101248 - r101251;
double r101253 = r101247 * r101247;
double r101254 = r101250 * r101250;
double r101255 = r101253 + r101254;
double r101256 = r101252 / r101255;
return r101256;
}
double f(double a, double b, double c, double d) {
double r101257 = b;
double r101258 = c;
double r101259 = r101257 * r101258;
double r101260 = a;
double r101261 = d;
double r101262 = r101260 * r101261;
double r101263 = r101259 - r101262;
double r101264 = r101258 * r101258;
double r101265 = r101261 * r101261;
double r101266 = r101264 + r101265;
double r101267 = r101263 / r101266;
double r101268 = -inf.0;
bool r101269 = r101267 <= r101268;
double r101270 = sqrt(r101266);
double r101271 = r101257 / r101270;
double r101272 = 1.4007558969236054e+294;
bool r101273 = r101267 <= r101272;
double r101274 = r101263 / r101270;
double r101275 = r101274 / r101270;
double r101276 = -r101260;
double r101277 = r101276 / r101270;
double r101278 = r101273 ? r101275 : r101277;
double r101279 = r101269 ? r101271 : r101278;
return r101279;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.4 |
|---|---|
| Target | 0.5 |
| Herbie | 25.1 |
if (/ (- (* b c) (* a d)) (+ (* c c) (* d d))) < -inf.0Initial program 64.0
rmApplied add-sqr-sqrt64.0
Applied associate-/r*64.0
Taylor expanded around inf 54.2
if -inf.0 < (/ (- (* b c) (* a d)) (+ (* c c) (* d d))) < 1.4007558969236054e+294Initial program 11.5
rmApplied add-sqr-sqrt11.5
Applied associate-/r*11.4
if 1.4007558969236054e+294 < (/ (- (* b c) (* a d)) (+ (* c c) (* d d))) Initial program 63.4
rmApplied add-sqr-sqrt63.4
Applied associate-/r*63.4
Taylor expanded around 0 60.2
Simplified60.2
Final simplification25.1
herbie shell --seed 2019199
(FPCore (a b c d)
:name "Complex division, imag part"
: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))))