\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\frac{\frac{c}{\mathsf{hypot}\left(d, c\right)} \cdot b - \frac{a}{\frac{\mathsf{hypot}\left(d, c\right)}{d}}}{\mathsf{hypot}\left(d, c\right)}double f(double a, double b, double c, double d) {
double r80413 = b;
double r80414 = c;
double r80415 = r80413 * r80414;
double r80416 = a;
double r80417 = d;
double r80418 = r80416 * r80417;
double r80419 = r80415 - r80418;
double r80420 = r80414 * r80414;
double r80421 = r80417 * r80417;
double r80422 = r80420 + r80421;
double r80423 = r80419 / r80422;
return r80423;
}
double f(double a, double b, double c, double d) {
double r80424 = c;
double r80425 = d;
double r80426 = hypot(r80425, r80424);
double r80427 = r80424 / r80426;
double r80428 = b;
double r80429 = r80427 * r80428;
double r80430 = a;
double r80431 = r80426 / r80425;
double r80432 = r80430 / r80431;
double r80433 = r80429 - r80432;
double r80434 = r80433 / r80426;
return r80434;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 25.9 |
|---|---|
| Target | 0.5 |
| Herbie | 0.6 |
Initial program 25.9
Simplified25.9
rmApplied add-sqr-sqrt25.9
Applied *-un-lft-identity25.9
Applied times-frac25.9
Simplified25.9
Simplified16.7
rmApplied pow116.7
Applied pow116.7
Applied pow-prod-down16.7
Simplified16.6
rmApplied div-sub16.6
Simplified9.1
Simplified0.6
Final simplification0.6
herbie shell --seed 2019326 +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))))