\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 r93958 = a;
double r93959 = c;
double r93960 = r93958 * r93959;
double r93961 = b;
double r93962 = d;
double r93963 = r93961 * r93962;
double r93964 = r93960 + r93963;
double r93965 = r93959 * r93959;
double r93966 = r93962 * r93962;
double r93967 = r93965 + r93966;
double r93968 = r93964 / r93967;
return r93968;
}
double f(double a, double b, double c, double d) {
double r93969 = a;
double r93970 = c;
double r93971 = r93969 * r93970;
double r93972 = b;
double r93973 = d;
double r93974 = r93972 * r93973;
double r93975 = r93971 + r93974;
double r93976 = r93970 * r93970;
double r93977 = r93973 * r93973;
double r93978 = r93976 + r93977;
double r93979 = r93975 / r93978;
return r93979;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.9 |
|---|---|
| Target | 0.4 |
| Herbie | 26.9 |
Initial program 26.9
rmApplied add-sqr-sqrt26.9
Applied associate-/r*26.8
Final simplification26.9
herbie shell --seed 2019297
(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))))