\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\frac{1}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{c \cdot b - d \cdot a}{\mathsf{hypot}\left(d, c\right)}double f(double a, double b, double c, double d) {
double r4982318 = b;
double r4982319 = c;
double r4982320 = r4982318 * r4982319;
double r4982321 = a;
double r4982322 = d;
double r4982323 = r4982321 * r4982322;
double r4982324 = r4982320 - r4982323;
double r4982325 = r4982319 * r4982319;
double r4982326 = r4982322 * r4982322;
double r4982327 = r4982325 + r4982326;
double r4982328 = r4982324 / r4982327;
return r4982328;
}
double f(double a, double b, double c, double d) {
double r4982329 = 1.0;
double r4982330 = d;
double r4982331 = c;
double r4982332 = hypot(r4982330, r4982331);
double r4982333 = r4982329 / r4982332;
double r4982334 = b;
double r4982335 = r4982331 * r4982334;
double r4982336 = a;
double r4982337 = r4982330 * r4982336;
double r4982338 = r4982335 - r4982337;
double r4982339 = r4982338 / r4982332;
double r4982340 = r4982333 * r4982339;
return r4982340;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.4 |
|---|---|
| Target | 0.5 |
| Herbie | 17.0 |
Initial program 26.4
Simplified26.4
rmApplied clear-num26.6
rmApplied *-un-lft-identity26.6
Applied add-sqr-sqrt26.6
Applied times-frac26.6
Applied add-cube-cbrt26.6
Applied times-frac26.5
Simplified26.5
Simplified17.0
Final simplification17.0
herbie shell --seed 2019174 +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))))