\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;c \le -9.626862058130032698667930010363888244365 \cdot 10^{163}:\\
\;\;\;\;\frac{-b}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \le 7.666528689436016414053909814985902231564 \cdot 10^{118}:\\
\;\;\;\;\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 r76817 = b;
double r76818 = c;
double r76819 = r76817 * r76818;
double r76820 = a;
double r76821 = d;
double r76822 = r76820 * r76821;
double r76823 = r76819 - r76822;
double r76824 = r76818 * r76818;
double r76825 = r76821 * r76821;
double r76826 = r76824 + r76825;
double r76827 = r76823 / r76826;
return r76827;
}
double f(double a, double b, double c, double d) {
double r76828 = c;
double r76829 = -9.626862058130033e+163;
bool r76830 = r76828 <= r76829;
double r76831 = b;
double r76832 = -r76831;
double r76833 = d;
double r76834 = hypot(r76828, r76833);
double r76835 = r76832 / r76834;
double r76836 = 7.666528689436016e+118;
bool r76837 = r76828 <= r76836;
double r76838 = a;
double r76839 = r76833 * r76838;
double r76840 = -r76839;
double r76841 = fma(r76831, r76828, r76840);
double r76842 = r76841 / r76834;
double r76843 = r76842 / r76834;
double r76844 = r76831 / r76834;
double r76845 = r76837 ? r76843 : r76844;
double r76846 = r76830 ? r76835 : r76845;
return r76846;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
| Original | 26.6 |
|---|---|
| Target | 0.5 |
| Herbie | 13.0 |
if c < -9.626862058130033e+163Initial program 44.5
rmApplied add-sqr-sqrt44.5
Applied *-un-lft-identity44.5
Applied times-frac44.5
Simplified44.5
Simplified29.6
rmApplied *-un-lft-identity29.6
Applied add-sqr-sqrt29.6
Applied times-frac29.6
Applied associate-*l*29.6
Simplified29.5
Taylor expanded around -inf 12.3
Simplified12.3
if -9.626862058130033e+163 < c < 7.666528689436016e+118Initial program 19.9
rmApplied add-sqr-sqrt19.9
Applied *-un-lft-identity19.9
Applied times-frac19.9
Simplified19.9
Simplified12.6
rmApplied *-un-lft-identity12.6
Applied add-sqr-sqrt12.6
Applied times-frac12.6
Applied associate-*l*12.6
Simplified12.4
if 7.666528689436016e+118 < c Initial program 42.3
rmApplied add-sqr-sqrt42.3
Applied *-un-lft-identity42.3
Applied times-frac42.3
Simplified42.3
Simplified27.9
rmApplied *-un-lft-identity27.9
Applied add-sqr-sqrt27.9
Applied times-frac27.9
Applied associate-*l*27.9
Simplified27.8
Taylor expanded around inf 16.1
Final simplification13.0
herbie shell --seed 2019347 +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))))