\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;c \le -4.002330886974353 \cdot 10^{-17} \lor \neg \left(c \le 3.4366687886863465 \cdot 10^{63}\right):\\
\;\;\;\;\frac{b}{\frac{{c}^{2} + {d}^{2}}{c}} - \frac{a \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot c}{c \cdot c + d \cdot d} - \frac{a}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{d}{\sqrt{c \cdot c + d \cdot d}}\\
\end{array}double f(double a, double b, double c, double d) {
double r119374 = b;
double r119375 = c;
double r119376 = r119374 * r119375;
double r119377 = a;
double r119378 = d;
double r119379 = r119377 * r119378;
double r119380 = r119376 - r119379;
double r119381 = r119375 * r119375;
double r119382 = r119378 * r119378;
double r119383 = r119381 + r119382;
double r119384 = r119380 / r119383;
return r119384;
}
double f(double a, double b, double c, double d) {
double r119385 = c;
double r119386 = -4.002330886974353e-17;
bool r119387 = r119385 <= r119386;
double r119388 = 3.4366687886863465e+63;
bool r119389 = r119385 <= r119388;
double r119390 = !r119389;
bool r119391 = r119387 || r119390;
double r119392 = b;
double r119393 = 2.0;
double r119394 = pow(r119385, r119393);
double r119395 = d;
double r119396 = pow(r119395, r119393);
double r119397 = r119394 + r119396;
double r119398 = r119397 / r119385;
double r119399 = r119392 / r119398;
double r119400 = a;
double r119401 = r119400 * r119395;
double r119402 = r119385 * r119385;
double r119403 = r119395 * r119395;
double r119404 = r119402 + r119403;
double r119405 = r119401 / r119404;
double r119406 = r119399 - r119405;
double r119407 = r119392 * r119385;
double r119408 = r119407 / r119404;
double r119409 = sqrt(r119404);
double r119410 = r119400 / r119409;
double r119411 = r119395 / r119409;
double r119412 = r119410 * r119411;
double r119413 = r119408 - r119412;
double r119414 = r119391 ? r119406 : r119413;
return r119414;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.2 |
|---|---|
| Target | 0.4 |
| Herbie | 23.7 |
if c < -4.002330886974353e-17 or 3.4366687886863465e+63 < c Initial program 33.9
rmApplied div-sub33.9
rmApplied associate-/l*30.5
Simplified30.5
if -4.002330886974353e-17 < c < 3.4366687886863465e+63Initial program 19.0
rmApplied div-sub19.0
rmApplied add-sqr-sqrt19.0
Applied times-frac17.2
Final simplification23.7
herbie shell --seed 2020057
(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))))