\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;d \le 1.937670017341036534919481795915749319496 \cdot 10^{62}:\\
\;\;\;\;\frac{\frac{1}{\sqrt{d \cdot d + c \cdot c}} \cdot \left(b \cdot c - d \cdot a\right)}{\sqrt{d \cdot d + c \cdot c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{-a}{\sqrt{d \cdot d + c \cdot c}}\\
\end{array}double f(double a, double b, double c, double d) {
double r6362476 = b;
double r6362477 = c;
double r6362478 = r6362476 * r6362477;
double r6362479 = a;
double r6362480 = d;
double r6362481 = r6362479 * r6362480;
double r6362482 = r6362478 - r6362481;
double r6362483 = r6362477 * r6362477;
double r6362484 = r6362480 * r6362480;
double r6362485 = r6362483 + r6362484;
double r6362486 = r6362482 / r6362485;
return r6362486;
}
double f(double a, double b, double c, double d) {
double r6362487 = d;
double r6362488 = 1.9376700173410365e+62;
bool r6362489 = r6362487 <= r6362488;
double r6362490 = 1.0;
double r6362491 = r6362487 * r6362487;
double r6362492 = c;
double r6362493 = r6362492 * r6362492;
double r6362494 = r6362491 + r6362493;
double r6362495 = sqrt(r6362494);
double r6362496 = r6362490 / r6362495;
double r6362497 = b;
double r6362498 = r6362497 * r6362492;
double r6362499 = a;
double r6362500 = r6362487 * r6362499;
double r6362501 = r6362498 - r6362500;
double r6362502 = r6362496 * r6362501;
double r6362503 = r6362502 / r6362495;
double r6362504 = -r6362499;
double r6362505 = r6362504 / r6362495;
double r6362506 = r6362489 ? r6362503 : r6362505;
return r6362506;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.3 |
|---|---|
| Target | 0.5 |
| Herbie | 26.3 |
if d < 1.9376700173410365e+62Initial program 23.4
rmApplied add-sqr-sqrt23.4
Applied associate-/r*23.3
rmApplied div-inv23.4
if 1.9376700173410365e+62 < d Initial program 37.3
rmApplied add-sqr-sqrt37.3
Applied associate-/r*37.2
Taylor expanded around 0 37.5
Simplified37.5
Final simplification26.3
herbie shell --seed 2019170
(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))))