\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;c \le -8.156571467291585296848265053911461752012 \cdot 10^{143}:\\
\;\;\;\;\frac{-b}{\mathsf{hypot}\left(c, d\right)} \cdot \sqrt{1}\\
\mathbf{elif}\;c \le 1.514468218294920189983723932644127325328 \cdot 10^{69}:\\
\;\;\;\;\sqrt{1} \cdot \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}:\\
\;\;\;\;\sqrt{1} \cdot \frac{b}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}double f(double a, double b, double c, double d) {
double r97761 = b;
double r97762 = c;
double r97763 = r97761 * r97762;
double r97764 = a;
double r97765 = d;
double r97766 = r97764 * r97765;
double r97767 = r97763 - r97766;
double r97768 = r97762 * r97762;
double r97769 = r97765 * r97765;
double r97770 = r97768 + r97769;
double r97771 = r97767 / r97770;
return r97771;
}
double f(double a, double b, double c, double d) {
double r97772 = c;
double r97773 = -8.156571467291585e+143;
bool r97774 = r97772 <= r97773;
double r97775 = b;
double r97776 = -r97775;
double r97777 = d;
double r97778 = hypot(r97772, r97777);
double r97779 = r97776 / r97778;
double r97780 = 1.0;
double r97781 = sqrt(r97780);
double r97782 = r97779 * r97781;
double r97783 = 1.5144682182949202e+69;
bool r97784 = r97772 <= r97783;
double r97785 = a;
double r97786 = r97777 * r97785;
double r97787 = -r97786;
double r97788 = fma(r97775, r97772, r97787);
double r97789 = r97788 / r97778;
double r97790 = r97789 / r97778;
double r97791 = r97781 * r97790;
double r97792 = r97775 / r97778;
double r97793 = r97781 * r97792;
double r97794 = r97784 ? r97791 : r97793;
double r97795 = r97774 ? r97782 : r97794;
return r97795;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
| Original | 26.0 |
|---|---|
| Target | 0.4 |
| Herbie | 13.2 |
if c < -8.156571467291585e+143Initial program 44.8
rmApplied add-sqr-sqrt44.8
Applied *-un-lft-identity44.8
Applied times-frac44.8
Simplified44.8
Simplified29.5
rmApplied *-un-lft-identity29.5
Applied add-sqr-sqrt29.5
Applied times-frac29.5
Applied associate-*l*29.5
Simplified29.4
Taylor expanded around -inf 14.9
Simplified14.9
if -8.156571467291585e+143 < c < 1.5144682182949202e+69Initial program 18.6
rmApplied add-sqr-sqrt18.6
Applied *-un-lft-identity18.6
Applied times-frac18.6
Simplified18.6
Simplified11.9
rmApplied *-un-lft-identity11.9
Applied add-sqr-sqrt11.9
Applied times-frac11.9
Applied associate-*l*11.9
Simplified11.8
if 1.5144682182949202e+69 < c Initial program 36.9
rmApplied add-sqr-sqrt36.9
Applied *-un-lft-identity36.9
Applied times-frac36.9
Simplified36.9
Simplified24.8
rmApplied *-un-lft-identity24.8
Applied add-sqr-sqrt24.8
Applied times-frac24.8
Applied associate-*l*24.8
Simplified24.7
Taylor expanded around inf 16.6
Final simplification13.2
herbie shell --seed 2019350 +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))))