\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;c \le -3.108106990901466 \cdot 10^{+219}:\\
\;\;\;\;-\frac{b}{\mathsf{hypot}\left(d, c\right)}\\
\mathbf{elif}\;c \le 5.1185396129683884 \cdot 10^{+128}:\\
\;\;\;\;\frac{\frac{b \cdot c - d \cdot a}{\mathsf{hypot}\left(d, c\right)}}{\mathsf{hypot}\left(d, c\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{\mathsf{hypot}\left(d, c\right)}\\
\end{array}double f(double a, double b, double c, double d) {
double r15179506 = b;
double r15179507 = c;
double r15179508 = r15179506 * r15179507;
double r15179509 = a;
double r15179510 = d;
double r15179511 = r15179509 * r15179510;
double r15179512 = r15179508 - r15179511;
double r15179513 = r15179507 * r15179507;
double r15179514 = r15179510 * r15179510;
double r15179515 = r15179513 + r15179514;
double r15179516 = r15179512 / r15179515;
return r15179516;
}
double f(double a, double b, double c, double d) {
double r15179517 = c;
double r15179518 = -3.108106990901466e+219;
bool r15179519 = r15179517 <= r15179518;
double r15179520 = b;
double r15179521 = d;
double r15179522 = hypot(r15179521, r15179517);
double r15179523 = r15179520 / r15179522;
double r15179524 = -r15179523;
double r15179525 = 5.1185396129683884e+128;
bool r15179526 = r15179517 <= r15179525;
double r15179527 = r15179520 * r15179517;
double r15179528 = a;
double r15179529 = r15179521 * r15179528;
double r15179530 = r15179527 - r15179529;
double r15179531 = r15179530 / r15179522;
double r15179532 = r15179531 / r15179522;
double r15179533 = r15179526 ? r15179532 : r15179523;
double r15179534 = r15179519 ? r15179524 : r15179533;
return r15179534;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.5 |
|---|---|
| Target | 0.5 |
| Herbie | 13.2 |
if c < -3.108106990901466e+219Initial program 42.3
Simplified42.3
rmApplied add-sqr-sqrt42.3
Applied associate-/r*42.3
rmApplied fma-udef42.3
Applied hypot-def42.3
rmApplied fma-udef42.3
Applied hypot-def31.3
Taylor expanded around -inf 11.6
Simplified11.6
if -3.108106990901466e+219 < c < 5.1185396129683884e+128Initial program 22.0
Simplified22.0
rmApplied add-sqr-sqrt22.0
Applied associate-/r*21.9
rmApplied fma-udef21.9
Applied hypot-def21.9
rmApplied fma-udef21.9
Applied hypot-def13.1
Taylor expanded around -inf 13.1
if 5.1185396129683884e+128 < c Initial program 41.3
Simplified41.3
rmApplied add-sqr-sqrt41.3
Applied associate-/r*41.3
rmApplied fma-udef41.3
Applied hypot-def41.3
rmApplied fma-udef41.3
Applied hypot-def26.7
Taylor expanded around inf 14.4
Final simplification13.2
herbie shell --seed 2019120 +o rules:numerics
(FPCore (a b c d)
:name "Complex division, imag part"
: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))))