\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 r1567260 = b;
double r1567261 = c;
double r1567262 = r1567260 * r1567261;
double r1567263 = a;
double r1567264 = d;
double r1567265 = r1567263 * r1567264;
double r1567266 = r1567262 - r1567265;
double r1567267 = r1567261 * r1567261;
double r1567268 = r1567264 * r1567264;
double r1567269 = r1567267 + r1567268;
double r1567270 = r1567266 / r1567269;
return r1567270;
}
double f(double a, double b, double c, double d) {
double r1567271 = c;
double r1567272 = -1.0127401874663891e+151;
bool r1567273 = r1567271 <= r1567272;
double r1567274 = b;
double r1567275 = d;
double r1567276 = hypot(r1567275, r1567271);
double r1567277 = r1567274 / r1567276;
double r1567278 = -r1567277;
double r1567279 = 1.6977188157374524e+71;
bool r1567280 = r1567271 <= r1567279;
double r1567281 = r1567274 * r1567271;
double r1567282 = a;
double r1567283 = r1567275 * r1567282;
double r1567284 = r1567281 - r1567283;
double r1567285 = r1567284 / r1567276;
double r1567286 = r1567285 / r1567276;
double r1567287 = r1567280 ? r1567286 : r1567277;
double r1567288 = r1567273 ? r1567278 : r1567287;
return r1567288;
}




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
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
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))))