\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}double f(double a, double b, double c, double d) {
double r78551 = a;
double r78552 = c;
double r78553 = r78551 * r78552;
double r78554 = b;
double r78555 = d;
double r78556 = r78554 * r78555;
double r78557 = r78553 + r78556;
double r78558 = r78552 * r78552;
double r78559 = r78555 * r78555;
double r78560 = r78558 + r78559;
double r78561 = r78557 / r78560;
return r78561;
}
double f(double a, double b, double c, double d) {
double r78562 = a;
double r78563 = c;
double r78564 = r78562 * r78563;
double r78565 = b;
double r78566 = d;
double r78567 = r78565 * r78566;
double r78568 = r78564 + r78567;
double r78569 = r78563 * r78563;
double r78570 = r78566 * r78566;
double r78571 = r78569 + r78570;
double r78572 = r78568 / r78571;
return r78572;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.2 |
|---|---|
| Target | 0.5 |
| Herbie | 26.2 |
Initial program 26.2
rmApplied add-sqr-sqrt26.2
Applied associate-/r*26.1
Final simplification26.2
herbie shell --seed 2019308
(FPCore (a b c d)
:name "Complex division, real part"
:precision binary64
: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))))