\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;c \le -2.5095625752469799 \cdot 10^{113}:\\
\;\;\;\;\frac{-1 \cdot b}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \le 1.04610986578791549 \cdot 10^{-126}:\\
\;\;\;\;\frac{\frac{b \cdot c - a \cdot d}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \le 4.02564099829727292 \cdot 10^{-53}:\\
\;\;\;\;\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}\;c \le 2.14277106081791793 \cdot 10^{130}:\\
\;\;\;\;\frac{\frac{b \cdot c - a \cdot d}{\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 r112784 = b;
double r112785 = c;
double r112786 = r112784 * r112785;
double r112787 = a;
double r112788 = d;
double r112789 = r112787 * r112788;
double r112790 = r112786 - r112789;
double r112791 = r112785 * r112785;
double r112792 = r112788 * r112788;
double r112793 = r112791 + r112792;
double r112794 = r112790 / r112793;
return r112794;
}
double f(double a, double b, double c, double d) {
double r112795 = c;
double r112796 = -2.50956257524698e+113;
bool r112797 = r112795 <= r112796;
double r112798 = -1.0;
double r112799 = b;
double r112800 = r112798 * r112799;
double r112801 = d;
double r112802 = hypot(r112795, r112801);
double r112803 = r112800 / r112802;
double r112804 = 1.0461098657879155e-126;
bool r112805 = r112795 <= r112804;
double r112806 = r112799 * r112795;
double r112807 = a;
double r112808 = r112807 * r112801;
double r112809 = r112806 - r112808;
double r112810 = r112809 / r112802;
double r112811 = r112810 / r112802;
double r112812 = 4.025640998297273e-53;
bool r112813 = r112795 <= r112812;
double r112814 = r112801 * r112801;
double r112815 = fma(r112795, r112795, r112814);
double r112816 = r112815 / r112795;
double r112817 = r112799 / r112816;
double r112818 = r112815 / r112801;
double r112819 = r112807 / r112818;
double r112820 = r112817 - r112819;
double r112821 = 2.142771060817918e+130;
bool r112822 = r112795 <= r112821;
double r112823 = r112799 / r112802;
double r112824 = r112822 ? r112811 : r112823;
double r112825 = r112813 ? r112820 : r112824;
double r112826 = r112805 ? r112811 : r112825;
double r112827 = r112797 ? r112803 : r112826;
return r112827;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
| Original | 26.2 |
|---|---|
| Target | 0.4 |
| Herbie | 13.2 |
if c < -2.50956257524698e+113Initial program 42.1
rmApplied add-sqr-sqrt42.1
Applied *-un-lft-identity42.1
Applied times-frac42.1
Simplified42.1
Simplified28.2
rmApplied associate-*r/28.2
Simplified28.1
Taylor expanded around -inf 16.2
if -2.50956257524698e+113 < c < 1.0461098657879155e-126 or 4.025640998297273e-53 < c < 2.142771060817918e+130Initial program 18.8
rmApplied add-sqr-sqrt18.8
Applied *-un-lft-identity18.8
Applied times-frac18.8
Simplified18.8
Simplified12.4
rmApplied associate-*r/12.4
Simplified12.3
if 1.0461098657879155e-126 < c < 4.025640998297273e-53Initial program 13.8
rmApplied div-sub13.8
Simplified13.3
Simplified11.0
if 2.142771060817918e+130 < c Initial program 43.1
rmApplied add-sqr-sqrt43.1
Applied *-un-lft-identity43.1
Applied times-frac43.1
Simplified43.1
Simplified27.8
rmApplied associate-*r/27.8
Simplified27.7
Taylor expanded around inf 14.6
Final simplification13.2
herbie shell --seed 2020049 +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))))