\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;c \le -4.4263537617510411 \cdot 10^{138} \lor \neg \left(c \le 8.23624815355425478 \cdot 10^{-31}\right):\\
\;\;\;\;\frac{b}{\frac{{d}^{2}}{c} + c} - \frac{a \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{\frac{{c}^{2} + {d}^{2}}{c}} - \frac{a}{\frac{c \cdot c + d \cdot d}{d}}\\
\end{array}double f(double a, double b, double c, double d) {
double r105432 = b;
double r105433 = c;
double r105434 = r105432 * r105433;
double r105435 = a;
double r105436 = d;
double r105437 = r105435 * r105436;
double r105438 = r105434 - r105437;
double r105439 = r105433 * r105433;
double r105440 = r105436 * r105436;
double r105441 = r105439 + r105440;
double r105442 = r105438 / r105441;
return r105442;
}
double f(double a, double b, double c, double d) {
double r105443 = c;
double r105444 = -4.426353761751041e+138;
bool r105445 = r105443 <= r105444;
double r105446 = 8.236248153554255e-31;
bool r105447 = r105443 <= r105446;
double r105448 = !r105447;
bool r105449 = r105445 || r105448;
double r105450 = b;
double r105451 = d;
double r105452 = 2.0;
double r105453 = pow(r105451, r105452);
double r105454 = r105453 / r105443;
double r105455 = r105454 + r105443;
double r105456 = r105450 / r105455;
double r105457 = a;
double r105458 = r105457 * r105451;
double r105459 = r105443 * r105443;
double r105460 = r105451 * r105451;
double r105461 = r105459 + r105460;
double r105462 = r105458 / r105461;
double r105463 = r105456 - r105462;
double r105464 = pow(r105443, r105452);
double r105465 = r105464 + r105453;
double r105466 = r105465 / r105443;
double r105467 = r105450 / r105466;
double r105468 = r105461 / r105451;
double r105469 = r105457 / r105468;
double r105470 = r105467 - r105469;
double r105471 = r105449 ? r105463 : r105470;
return r105471;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.5 |
|---|---|
| Target | 0.4 |
| Herbie | 16.2 |
if c < -4.426353761751041e+138 or 8.236248153554255e-31 < c Initial program 34.9
rmApplied div-sub34.9
rmApplied associate-/l*32.2
Simplified32.2
Taylor expanded around 0 15.5
if -4.426353761751041e+138 < c < 8.236248153554255e-31Initial program 19.9
rmApplied div-sub19.9
rmApplied associate-/l*19.3
Simplified19.3
rmApplied associate-/l*16.7
Final simplification16.2
herbie shell --seed 2020060
(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))))