\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\frac{\frac{b \cdot d + a \cdot c}{\sqrt{c \cdot c + d \cdot d}}}{\sqrt{c \cdot c + d \cdot d}}double f(double a, double b, double c, double d) {
double r3914367 = a;
double r3914368 = c;
double r3914369 = r3914367 * r3914368;
double r3914370 = b;
double r3914371 = d;
double r3914372 = r3914370 * r3914371;
double r3914373 = r3914369 + r3914372;
double r3914374 = r3914368 * r3914368;
double r3914375 = r3914371 * r3914371;
double r3914376 = r3914374 + r3914375;
double r3914377 = r3914373 / r3914376;
return r3914377;
}
double f(double a, double b, double c, double d) {
double r3914378 = b;
double r3914379 = d;
double r3914380 = r3914378 * r3914379;
double r3914381 = a;
double r3914382 = c;
double r3914383 = r3914381 * r3914382;
double r3914384 = r3914380 + r3914383;
double r3914385 = r3914382 * r3914382;
double r3914386 = r3914379 * r3914379;
double r3914387 = r3914385 + r3914386;
double r3914388 = sqrt(r3914387);
double r3914389 = r3914384 / r3914388;
double r3914390 = r3914389 / r3914388;
return r3914390;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 25.7 |
|---|---|
| Target | 0.4 |
| Herbie | 25.7 |
Initial program 25.7
rmApplied add-sqr-sqrt25.7
Applied associate-/r*25.7
rmApplied div-inv25.7
rmApplied un-div-inv25.7
Final simplification25.7
herbie shell --seed 2019152
(FPCore (a b c d)
:name "Complex division, real part"
:herbie-target
(if (< (fabs d) (fabs c)) (/ (+ a (* b (/ d c))) (+ c (* d (/ d c)))) (/ (+ b (* a (/ c d))) (+ d (* c (/ c d)))))
(/ (+ (* a c) (* b d)) (+ (* c c) (* d d))))