\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;c \le -4.431736220616081 \cdot 10^{+97}:\\
\;\;\;\;-\frac{b}{\mathsf{hypot}\left(d, c\right)}\\
\mathbf{elif}\;c \le 6.920723654382158 \cdot 10^{+133}:\\
\;\;\;\;\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 r2593306 = b;
double r2593307 = c;
double r2593308 = r2593306 * r2593307;
double r2593309 = a;
double r2593310 = d;
double r2593311 = r2593309 * r2593310;
double r2593312 = r2593308 - r2593311;
double r2593313 = r2593307 * r2593307;
double r2593314 = r2593310 * r2593310;
double r2593315 = r2593313 + r2593314;
double r2593316 = r2593312 / r2593315;
return r2593316;
}
double f(double a, double b, double c, double d) {
double r2593317 = c;
double r2593318 = -4.431736220616081e+97;
bool r2593319 = r2593317 <= r2593318;
double r2593320 = b;
double r2593321 = d;
double r2593322 = hypot(r2593321, r2593317);
double r2593323 = r2593320 / r2593322;
double r2593324 = -r2593323;
double r2593325 = 6.920723654382158e+133;
bool r2593326 = r2593317 <= r2593325;
double r2593327 = r2593320 * r2593317;
double r2593328 = a;
double r2593329 = r2593321 * r2593328;
double r2593330 = r2593327 - r2593329;
double r2593331 = r2593330 / r2593322;
double r2593332 = r2593331 / r2593322;
double r2593333 = r2593326 ? r2593332 : r2593323;
double r2593334 = r2593319 ? r2593324 : r2593333;
return r2593334;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.1 |
|---|---|
| Target | 0.5 |
| Herbie | 13.0 |
if c < -4.431736220616081e+97Initial program 39.3
Simplified39.3
rmApplied add-sqr-sqrt39.3
Applied associate-/r*39.3
rmApplied div-inv39.3
rmApplied fma-udef39.3
Applied hypot-def39.3
Taylor expanded around -inf 17.3
Simplified17.3
if -4.431736220616081e+97 < c < 6.920723654382158e+133Initial program 19.0
Simplified19.0
rmApplied add-sqr-sqrt19.0
Applied associate-/r*18.9
rmApplied div-inv19.0
rmApplied fma-udef19.0
Applied hypot-def19.0
rmApplied *-un-lft-identity19.0
Applied associate-/r*19.0
Simplified11.7
if 6.920723654382158e+133 < c Initial program 41.4
Simplified41.4
rmApplied add-sqr-sqrt41.4
Applied associate-/r*41.4
rmApplied div-inv41.4
rmApplied fma-udef41.4
Applied hypot-def41.4
Taylor expanded around inf 13.7
Final simplification13.0
herbie shell --seed 2019146 +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))))