\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\frac{\frac{1}{\sqrt{c \cdot c + d \cdot d}} \cdot \left(b \cdot d + a \cdot c\right)}{\sqrt{c \cdot c + d \cdot d}}double f(double a, double b, double c, double d) {
double r2817366 = a;
double r2817367 = c;
double r2817368 = r2817366 * r2817367;
double r2817369 = b;
double r2817370 = d;
double r2817371 = r2817369 * r2817370;
double r2817372 = r2817368 + r2817371;
double r2817373 = r2817367 * r2817367;
double r2817374 = r2817370 * r2817370;
double r2817375 = r2817373 + r2817374;
double r2817376 = r2817372 / r2817375;
return r2817376;
}
double f(double a, double b, double c, double d) {
double r2817377 = 1.0;
double r2817378 = c;
double r2817379 = r2817378 * r2817378;
double r2817380 = d;
double r2817381 = r2817380 * r2817380;
double r2817382 = r2817379 + r2817381;
double r2817383 = sqrt(r2817382);
double r2817384 = r2817377 / r2817383;
double r2817385 = b;
double r2817386 = r2817385 * r2817380;
double r2817387 = a;
double r2817388 = r2817387 * r2817378;
double r2817389 = r2817386 + r2817388;
double r2817390 = r2817384 * r2817389;
double r2817391 = r2817390 / r2817383;
return r2817391;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 25.8 |
|---|---|
| Target | 0.5 |
| Herbie | 25.8 |
Initial program 25.8
rmApplied add-sqr-sqrt25.8
Applied associate-/r*25.8
rmApplied div-inv25.8
Final simplification25.8
herbie shell --seed 2019139
(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))))