\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\frac{\frac{b}{\frac{\sqrt{c \cdot c + d \cdot d}}{c}}}{\left|\sqrt[3]{c \cdot c + d \cdot d}\right| \cdot \sqrt{\sqrt[3]{c \cdot c + d \cdot d}}} - \frac{a}{\frac{c}{\frac{d}{c}} + d}double f(double a, double b, double c, double d) {
double r189522 = b;
double r189523 = c;
double r189524 = r189522 * r189523;
double r189525 = a;
double r189526 = d;
double r189527 = r189525 * r189526;
double r189528 = r189524 - r189527;
double r189529 = r189523 * r189523;
double r189530 = r189526 * r189526;
double r189531 = r189529 + r189530;
double r189532 = r189528 / r189531;
return r189532;
}
double f(double a, double b, double c, double d) {
double r189533 = b;
double r189534 = c;
double r189535 = r189534 * r189534;
double r189536 = d;
double r189537 = r189536 * r189536;
double r189538 = r189535 + r189537;
double r189539 = sqrt(r189538);
double r189540 = r189539 / r189534;
double r189541 = r189533 / r189540;
double r189542 = cbrt(r189538);
double r189543 = fabs(r189542);
double r189544 = sqrt(r189542);
double r189545 = r189543 * r189544;
double r189546 = r189541 / r189545;
double r189547 = a;
double r189548 = r189536 / r189534;
double r189549 = r189534 / r189548;
double r189550 = r189549 + r189536;
double r189551 = r189547 / r189550;
double r189552 = r189546 - r189551;
return r189552;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 25.9 |
|---|---|
| Target | 0.4 |
| Herbie | 13.8 |
Initial program 25.9
rmApplied div-sub25.9
Simplified24.3
Taylor expanded around 0 17.5
Simplified16.0
rmApplied add-sqr-sqrt16.0
Applied associate-/r*15.9
Simplified13.7
rmApplied add-cube-cbrt13.8
Applied sqrt-prod13.8
Simplified13.8
Final simplification13.8
herbie shell --seed 2019195
(FPCore (a b c d)
:name "Complex division, imag part"
:herbie-target
(if (< (fabs d) (fabs c)) (/ (- b (* a (/ d c))) (+ c (* d (/ d c)))) (/ (+ (- a) (* b (/ c d))) (+ d (* c (/ c d)))))
(/ (- (* b c) (* a d)) (+ (* c c) (* d d))))