\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;c \le -1.0127401874663891 \cdot 10^{+151}:\\
\;\;\;\;-\frac{b}{\mathsf{hypot}\left(d, c\right)}\\
\mathbf{elif}\;c \le 1.6977188157374524 \cdot 10^{+71}:\\
\;\;\;\;\frac{\frac{b \cdot c - d \cdot a}{\mathsf{hypot}\left(d, c\right)}}{\mathsf{hypot}\left(d, c\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{\mathsf{hypot}\left(d, c\right)}\\
\end{array}double f(double a, double b, double c, double d) {
double r2299038 = b;
double r2299039 = c;
double r2299040 = r2299038 * r2299039;
double r2299041 = a;
double r2299042 = d;
double r2299043 = r2299041 * r2299042;
double r2299044 = r2299040 - r2299043;
double r2299045 = r2299039 * r2299039;
double r2299046 = r2299042 * r2299042;
double r2299047 = r2299045 + r2299046;
double r2299048 = r2299044 / r2299047;
return r2299048;
}
double f(double a, double b, double c, double d) {
double r2299049 = c;
double r2299050 = -1.0127401874663891e+151;
bool r2299051 = r2299049 <= r2299050;
double r2299052 = b;
double r2299053 = d;
double r2299054 = hypot(r2299053, r2299049);
double r2299055 = r2299052 / r2299054;
double r2299056 = -r2299055;
double r2299057 = 1.6977188157374524e+71;
bool r2299058 = r2299049 <= r2299057;
double r2299059 = r2299052 * r2299049;
double r2299060 = a;
double r2299061 = r2299053 * r2299060;
double r2299062 = r2299059 - r2299061;
double r2299063 = r2299062 / r2299054;
double r2299064 = r2299063 / r2299054;
double r2299065 = r2299058 ? r2299064 : r2299055;
double r2299066 = r2299051 ? r2299056 : r2299065;
return r2299066;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 25.6 |
|---|---|
| Target | 0.4 |
| Herbie | 12.9 |
if c < -1.0127401874663891e+151Initial program 43.5
Simplified43.5
rmApplied add-sqr-sqrt43.5
Applied associate-/r*43.5
rmApplied fma-udef43.5
Applied hypot-def43.5
rmApplied fma-udef43.5
Applied hypot-def28.4
Taylor expanded around -inf 13.0
Simplified13.0
if -1.0127401874663891e+151 < c < 1.6977188157374524e+71Initial program 18.8
Simplified18.8
rmApplied add-sqr-sqrt18.8
Applied associate-/r*18.7
rmApplied fma-udef18.7
Applied hypot-def18.7
rmApplied fma-udef18.7
Applied hypot-def11.5
if 1.6977188157374524e+71 < c Initial program 35.8
Simplified35.8
rmApplied add-sqr-sqrt35.8
Applied associate-/r*35.8
rmApplied fma-udef35.8
Applied hypot-def35.8
rmApplied fma-udef35.8
Applied hypot-def23.5
Taylor expanded around inf 17.3
Final simplification12.9
herbie shell --seed 2019153 +o rules:numerics
(FPCore (a b c d)
:name "Complex division, imag part"
: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))))