\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;c \le -2.06095728035008259 \cdot 10^{150}:\\
\;\;\;\;\frac{-1 \cdot b}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \le 1.04482715632166882 \cdot 10^{105}:\\
\;\;\;\;\frac{\left(b \cdot c - a \cdot d\right) \cdot \frac{1}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}double f(double a, double b, double c, double d) {
double r111451 = b;
double r111452 = c;
double r111453 = r111451 * r111452;
double r111454 = a;
double r111455 = d;
double r111456 = r111454 * r111455;
double r111457 = r111453 - r111456;
double r111458 = r111452 * r111452;
double r111459 = r111455 * r111455;
double r111460 = r111458 + r111459;
double r111461 = r111457 / r111460;
return r111461;
}
double f(double a, double b, double c, double d) {
double r111462 = c;
double r111463 = -2.0609572803500826e+150;
bool r111464 = r111462 <= r111463;
double r111465 = -1.0;
double r111466 = b;
double r111467 = r111465 * r111466;
double r111468 = d;
double r111469 = hypot(r111462, r111468);
double r111470 = r111467 / r111469;
double r111471 = 1.0448271563216688e+105;
bool r111472 = r111462 <= r111471;
double r111473 = r111466 * r111462;
double r111474 = a;
double r111475 = r111474 * r111468;
double r111476 = r111473 - r111475;
double r111477 = 1.0;
double r111478 = r111477 / r111469;
double r111479 = r111476 * r111478;
double r111480 = r111479 / r111469;
double r111481 = r111466 / r111469;
double r111482 = r111472 ? r111480 : r111481;
double r111483 = r111464 ? r111470 : r111482;
return r111483;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.3 |
|---|---|
| Target | 0.4 |
| Herbie | 13.1 |
if c < -2.0609572803500826e+150Initial program 44.3
rmApplied add-sqr-sqrt44.3
Applied *-un-lft-identity44.3
Applied times-frac44.3
Simplified44.3
Simplified27.8
rmApplied associate-*r/27.8
Simplified27.8
Taylor expanded around -inf 13.0
if -2.0609572803500826e+150 < c < 1.0448271563216688e+105Initial program 19.2
rmApplied add-sqr-sqrt19.2
Applied *-un-lft-identity19.2
Applied times-frac19.2
Simplified19.2
Simplified12.4
rmApplied associate-*r/12.3
Simplified12.2
rmApplied div-inv12.3
if 1.0448271563216688e+105 < c Initial program 39.7
rmApplied add-sqr-sqrt39.7
Applied *-un-lft-identity39.7
Applied times-frac39.8
Simplified39.8
Simplified27.1
rmApplied associate-*r/27.1
Simplified27.1
Taylor expanded around inf 16.2
Final simplification13.1
herbie shell --seed 2020039 +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))))