\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\frac{\frac{\frac{d}{\frac{\left|\sqrt[3]{c \cdot c + d \cdot d}\right|}{b}} + \frac{a \cdot c}{\left|\sqrt[3]{c \cdot c + d \cdot d}\right|}}{\sqrt{\sqrt[3]{c \cdot c + d \cdot d}}}}{\sqrt{c \cdot c + d \cdot d}}double f(double a, double b, double c, double d) {
double r121058 = a;
double r121059 = c;
double r121060 = r121058 * r121059;
double r121061 = b;
double r121062 = d;
double r121063 = r121061 * r121062;
double r121064 = r121060 + r121063;
double r121065 = r121059 * r121059;
double r121066 = r121062 * r121062;
double r121067 = r121065 + r121066;
double r121068 = r121064 / r121067;
return r121068;
}
double f(double a, double b, double c, double d) {
double r121069 = d;
double r121070 = c;
double r121071 = r121070 * r121070;
double r121072 = r121069 * r121069;
double r121073 = r121071 + r121072;
double r121074 = cbrt(r121073);
double r121075 = fabs(r121074);
double r121076 = b;
double r121077 = r121075 / r121076;
double r121078 = r121069 / r121077;
double r121079 = a;
double r121080 = r121079 * r121070;
double r121081 = r121080 / r121075;
double r121082 = r121078 + r121081;
double r121083 = sqrt(r121074);
double r121084 = r121082 / r121083;
double r121085 = sqrt(r121073);
double r121086 = r121084 / r121085;
return r121086;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.8 |
|---|---|
| Target | 0.5 |
| Herbie | 25.8 |
Initial program 26.8
rmApplied add-sqr-sqrt26.8
Applied associate-/r*26.7
rmApplied add-cube-cbrt27.0
Applied sqrt-prod27.0
Applied associate-/r*27.0
Simplified27.0
Taylor expanded around 0 28.7
Simplified25.8
Final simplification25.8
herbie shell --seed 2020042
(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))))