\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 r93441 = b;
double r93442 = c;
double r93443 = r93441 * r93442;
double r93444 = a;
double r93445 = d;
double r93446 = r93444 * r93445;
double r93447 = r93443 - r93446;
double r93448 = r93442 * r93442;
double r93449 = r93445 * r93445;
double r93450 = r93448 + r93449;
double r93451 = r93447 / r93450;
return r93451;
}
double f(double a, double b, double c, double d) {
double r93452 = c;
double r93453 = -4.426353761751041e+138;
bool r93454 = r93452 <= r93453;
double r93455 = 8.236248153554255e-31;
bool r93456 = r93452 <= r93455;
double r93457 = !r93456;
bool r93458 = r93454 || r93457;
double r93459 = b;
double r93460 = d;
double r93461 = 2.0;
double r93462 = pow(r93460, r93461);
double r93463 = r93462 / r93452;
double r93464 = r93463 + r93452;
double r93465 = r93459 / r93464;
double r93466 = a;
double r93467 = r93466 * r93460;
double r93468 = r93452 * r93452;
double r93469 = r93460 * r93460;
double r93470 = r93468 + r93469;
double r93471 = r93467 / r93470;
double r93472 = r93465 - r93471;
double r93473 = pow(r93452, r93461);
double r93474 = r93473 + r93462;
double r93475 = r93474 / r93452;
double r93476 = r93459 / r93475;
double r93477 = r93470 / r93460;
double r93478 = r93466 / r93477;
double r93479 = r93476 - r93478;
double r93480 = r93458 ? r93472 : r93479;
return r93480;
}




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))))