\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;c \le -2.2616143508082277 \cdot 10^{79} \lor \neg \left(c \le 1.03827084215452011 \cdot 10^{-35}\right):\\
\;\;\;\;\frac{\frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}}}{\mathsf{hypot}\left(c, d\right)} - \frac{\frac{a \cdot d}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{b \cdot c}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)} - \frac{\frac{a}{1}}{\frac{\mathsf{hypot}\left(c, d\right)}{\frac{d}{\mathsf{hypot}\left(c, d\right)}}}\\
\end{array}double f(double a, double b, double c, double d) {
double r114390 = b;
double r114391 = c;
double r114392 = r114390 * r114391;
double r114393 = a;
double r114394 = d;
double r114395 = r114393 * r114394;
double r114396 = r114392 - r114395;
double r114397 = r114391 * r114391;
double r114398 = r114394 * r114394;
double r114399 = r114397 + r114398;
double r114400 = r114396 / r114399;
return r114400;
}
double f(double a, double b, double c, double d) {
double r114401 = c;
double r114402 = -2.2616143508082277e+79;
bool r114403 = r114401 <= r114402;
double r114404 = 1.0382708421545201e-35;
bool r114405 = r114401 <= r114404;
double r114406 = !r114405;
bool r114407 = r114403 || r114406;
double r114408 = b;
double r114409 = d;
double r114410 = hypot(r114401, r114409);
double r114411 = r114410 / r114401;
double r114412 = r114408 / r114411;
double r114413 = r114412 / r114410;
double r114414 = a;
double r114415 = r114414 * r114409;
double r114416 = r114415 / r114410;
double r114417 = r114416 / r114410;
double r114418 = r114413 - r114417;
double r114419 = r114408 * r114401;
double r114420 = r114419 / r114410;
double r114421 = r114420 / r114410;
double r114422 = 1.0;
double r114423 = r114414 / r114422;
double r114424 = r114409 / r114410;
double r114425 = r114410 / r114424;
double r114426 = r114423 / r114425;
double r114427 = r114421 - r114426;
double r114428 = r114407 ? r114418 : r114427;
return r114428;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.5 |
|---|---|
| Target | 0.4 |
| Herbie | 4.8 |
if c < -2.2616143508082277e+79 or 1.0382708421545201e-35 < c Initial program 33.6
rmApplied add-sqr-sqrt33.6
Applied *-un-lft-identity33.6
Applied times-frac33.6
Simplified33.6
Simplified23.3
rmApplied associate-*r/23.2
Simplified23.2
rmApplied div-sub23.2
Applied div-sub23.2
rmApplied associate-/l*7.8
if -2.2616143508082277e+79 < c < 1.0382708421545201e-35Initial program 19.6
rmApplied add-sqr-sqrt19.6
Applied *-un-lft-identity19.6
Applied times-frac19.6
Simplified19.6
Simplified11.8
rmApplied associate-*r/11.7
Simplified11.7
rmApplied div-sub11.7
Applied div-sub11.7
rmApplied *-un-lft-identity11.7
Applied times-frac1.7
Applied associate-/l*1.9
Final simplification4.8
herbie shell --seed 2020060 +o rules:numerics
(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))))