\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;c \le -1.048053858889701642136904508069161986597 \cdot 10^{111}:\\
\;\;\;\;\frac{-b}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \le 1.386924094392353157197647617615964799648 \cdot 10^{108}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(b, c, -d \cdot a\right)}{\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 r86711 = b;
double r86712 = c;
double r86713 = r86711 * r86712;
double r86714 = a;
double r86715 = d;
double r86716 = r86714 * r86715;
double r86717 = r86713 - r86716;
double r86718 = r86712 * r86712;
double r86719 = r86715 * r86715;
double r86720 = r86718 + r86719;
double r86721 = r86717 / r86720;
return r86721;
}
double f(double a, double b, double c, double d) {
double r86722 = c;
double r86723 = -1.0480538588897016e+111;
bool r86724 = r86722 <= r86723;
double r86725 = b;
double r86726 = -r86725;
double r86727 = d;
double r86728 = hypot(r86722, r86727);
double r86729 = r86726 / r86728;
double r86730 = 1.3869240943923532e+108;
bool r86731 = r86722 <= r86730;
double r86732 = a;
double r86733 = r86727 * r86732;
double r86734 = -r86733;
double r86735 = fma(r86725, r86722, r86734);
double r86736 = r86735 / r86728;
double r86737 = r86736 / r86728;
double r86738 = r86725 / r86728;
double r86739 = r86731 ? r86737 : r86738;
double r86740 = r86724 ? r86729 : r86739;
return r86740;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
| Original | 25.8 |
|---|---|
| Target | 0.4 |
| Herbie | 13.1 |
if c < -1.0480538588897016e+111Initial program 42.0
rmApplied add-sqr-sqrt42.0
Applied *-un-lft-identity42.0
Applied times-frac42.0
Simplified42.0
Simplified29.3
rmApplied *-un-lft-identity29.3
Applied add-sqr-sqrt29.3
Applied times-frac29.3
Applied associate-*l*29.3
Simplified29.3
Taylor expanded around -inf 16.4
Simplified16.4
if -1.0480538588897016e+111 < c < 1.3869240943923532e+108Initial program 17.8
rmApplied add-sqr-sqrt17.8
Applied *-un-lft-identity17.8
Applied times-frac17.8
Simplified17.8
Simplified11.3
rmApplied *-un-lft-identity11.3
Applied add-sqr-sqrt11.3
Applied times-frac11.3
Applied associate-*l*11.3
Simplified11.2
if 1.3869240943923532e+108 < c Initial program 40.8
rmApplied add-sqr-sqrt40.8
Applied *-un-lft-identity40.8
Applied times-frac40.8
Simplified40.8
Simplified28.1
rmApplied *-un-lft-identity28.1
Applied add-sqr-sqrt28.1
Applied times-frac28.1
Applied associate-*l*28.1
Simplified28.0
Taylor expanded around inf 17.0
Final simplification13.1
herbie shell --seed 2019303 +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))))