\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 r146294 = a;
double r146295 = c;
double r146296 = r146294 * r146295;
double r146297 = b;
double r146298 = d;
double r146299 = r146297 * r146298;
double r146300 = r146296 + r146299;
double r146301 = r146295 * r146295;
double r146302 = r146298 * r146298;
double r146303 = r146301 + r146302;
double r146304 = r146300 / r146303;
return r146304;
}
double f(double a, double b, double c, double d) {
double r146305 = d;
double r146306 = c;
double r146307 = r146306 * r146306;
double r146308 = r146305 * r146305;
double r146309 = r146307 + r146308;
double r146310 = cbrt(r146309);
double r146311 = fabs(r146310);
double r146312 = b;
double r146313 = r146311 / r146312;
double r146314 = r146305 / r146313;
double r146315 = a;
double r146316 = r146315 * r146306;
double r146317 = r146316 / r146311;
double r146318 = r146314 + r146317;
double r146319 = sqrt(r146310);
double r146320 = r146318 / r146319;
double r146321 = sqrt(r146309);
double r146322 = r146320 / r146321;
return r146322;
}




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))))