\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\begin{array}{l}
\mathbf{if}\;c \le -2.8763806766248217 \cdot 10^{136}:\\
\;\;\;\;1 \cdot \frac{-1 \cdot b}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \le 6.60217994199644213 \cdot 10^{202}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right) \cdot 1} \cdot \frac{\mathsf{fma}\left(b, c, -a \cdot d\right)}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;1 \cdot \frac{b}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}double f(double a, double b, double c, double d) {
double r107367 = b;
double r107368 = c;
double r107369 = r107367 * r107368;
double r107370 = a;
double r107371 = d;
double r107372 = r107370 * r107371;
double r107373 = r107369 - r107372;
double r107374 = r107368 * r107368;
double r107375 = r107371 * r107371;
double r107376 = r107374 + r107375;
double r107377 = r107373 / r107376;
return r107377;
}
double f(double a, double b, double c, double d) {
double r107378 = c;
double r107379 = -2.8763806766248217e+136;
bool r107380 = r107378 <= r107379;
double r107381 = 1.0;
double r107382 = -1.0;
double r107383 = b;
double r107384 = r107382 * r107383;
double r107385 = d;
double r107386 = hypot(r107378, r107385);
double r107387 = r107384 / r107386;
double r107388 = r107381 * r107387;
double r107389 = 6.602179941996442e+202;
bool r107390 = r107378 <= r107389;
double r107391 = r107386 * r107381;
double r107392 = r107381 / r107391;
double r107393 = a;
double r107394 = r107393 * r107385;
double r107395 = -r107394;
double r107396 = fma(r107383, r107378, r107395);
double r107397 = r107396 / r107386;
double r107398 = r107392 * r107397;
double r107399 = r107383 / r107386;
double r107400 = r107381 * r107399;
double r107401 = r107390 ? r107398 : r107400;
double r107402 = r107380 ? r107388 : r107401;
return r107402;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
| Original | 26.1 |
|---|---|
| Target | 0.5 |
| Herbie | 13.3 |
if c < -2.8763806766248217e+136Initial program 41.7
rmApplied add-sqr-sqrt41.7
Applied *-un-lft-identity41.7
Applied times-frac41.7
Simplified41.7
Simplified27.3
rmApplied *-un-lft-identity27.3
Applied associate-*l*27.3
Simplified27.2
Taylor expanded around -inf 15.1
if -2.8763806766248217e+136 < c < 6.602179941996442e+202Initial program 21.3
rmApplied add-sqr-sqrt21.3
Applied *-un-lft-identity21.3
Applied times-frac21.3
Simplified21.3
Simplified13.1
rmApplied fma-neg13.1
if 6.602179941996442e+202 < c Initial program 41.0
rmApplied add-sqr-sqrt41.0
Applied *-un-lft-identity41.0
Applied times-frac41.0
Simplified41.0
Simplified29.3
rmApplied *-un-lft-identity29.3
Applied associate-*l*29.3
Simplified29.2
Taylor expanded around inf 12.0
Final simplification13.3
herbie shell --seed 2020018 +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))))