\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \le -1033969720.49365747:\\
\;\;\;\;\frac{b}{\frac{\mathsf{fma}\left(c, c, d \cdot d\right)}{c}} - \frac{a}{\frac{\mathsf{fma}\left(c, c, d \cdot d\right)}{d}}\\
\mathbf{elif}\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \le 7.8735811135706561 \cdot 10^{304}:\\
\;\;\;\;\sqrt{\frac{1}{\mathsf{hypot}\left(c, d\right) \cdot 1}} \cdot \left(\sqrt{\frac{1}{\mathsf{hypot}\left(c, d\right) \cdot 1}} \cdot \frac{b \cdot c - a \cdot d}{\mathsf{hypot}\left(c, d\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{-1 \cdot a}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}double f(double a, double b, double c, double d) {
double r118640 = b;
double r118641 = c;
double r118642 = r118640 * r118641;
double r118643 = a;
double r118644 = d;
double r118645 = r118643 * r118644;
double r118646 = r118642 - r118645;
double r118647 = r118641 * r118641;
double r118648 = r118644 * r118644;
double r118649 = r118647 + r118648;
double r118650 = r118646 / r118649;
return r118650;
}
double f(double a, double b, double c, double d) {
double r118651 = b;
double r118652 = c;
double r118653 = r118651 * r118652;
double r118654 = a;
double r118655 = d;
double r118656 = r118654 * r118655;
double r118657 = r118653 - r118656;
double r118658 = r118652 * r118652;
double r118659 = r118655 * r118655;
double r118660 = r118658 + r118659;
double r118661 = r118657 / r118660;
double r118662 = -1033969720.4936575;
bool r118663 = r118661 <= r118662;
double r118664 = fma(r118652, r118652, r118659);
double r118665 = r118664 / r118652;
double r118666 = r118651 / r118665;
double r118667 = r118664 / r118655;
double r118668 = r118654 / r118667;
double r118669 = r118666 - r118668;
double r118670 = 7.873581113570656e+304;
bool r118671 = r118661 <= r118670;
double r118672 = 1.0;
double r118673 = hypot(r118652, r118655);
double r118674 = r118673 * r118672;
double r118675 = r118672 / r118674;
double r118676 = sqrt(r118675);
double r118677 = r118657 / r118673;
double r118678 = r118676 * r118677;
double r118679 = r118676 * r118678;
double r118680 = -1.0;
double r118681 = r118680 * r118654;
double r118682 = r118681 / r118673;
double r118683 = r118671 ? r118679 : r118682;
double r118684 = r118663 ? r118669 : r118683;
return r118684;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
| Original | 26.6 |
|---|---|
| Target | 0.5 |
| Herbie | 13.6 |
if (/ (- (* b c) (* a d)) (+ (* c c) (* d d))) < -1033969720.4936575Initial program 17.1
rmApplied div-sub17.1
Simplified11.1
Simplified5.8
if -1033969720.4936575 < (/ (- (* b c) (* a d)) (+ (* c c) (* d d))) < 7.873581113570656e+304Initial program 13.4
rmApplied add-sqr-sqrt13.4
Applied *-un-lft-identity13.4
Applied times-frac13.4
Simplified13.4
Simplified0.9
rmApplied add-sqr-sqrt1.1
Applied associate-*l*1.1
if 7.873581113570656e+304 < (/ (- (* b c) (* a d)) (+ (* c c) (* d d))) Initial program 63.7
rmApplied add-sqr-sqrt63.7
Applied *-un-lft-identity63.7
Applied times-frac63.7
Simplified63.7
Simplified61.2
rmApplied associate-*r/61.2
Simplified61.2
Taylor expanded around 0 48.5
Final simplification13.6
herbie shell --seed 2020025 +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))))