\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\frac{b}{\frac{d}{\frac{c}{d}} + c} - \frac{a}{\frac{c}{\frac{d}{c}} + d}double f(double a, double b, double c, double d) {
double r102609 = b;
double r102610 = c;
double r102611 = r102609 * r102610;
double r102612 = a;
double r102613 = d;
double r102614 = r102612 * r102613;
double r102615 = r102611 - r102614;
double r102616 = r102610 * r102610;
double r102617 = r102613 * r102613;
double r102618 = r102616 + r102617;
double r102619 = r102615 / r102618;
return r102619;
}
double f(double a, double b, double c, double d) {
double r102620 = b;
double r102621 = d;
double r102622 = c;
double r102623 = r102622 / r102621;
double r102624 = r102621 / r102623;
double r102625 = r102624 + r102622;
double r102626 = r102620 / r102625;
double r102627 = a;
double r102628 = r102621 / r102622;
double r102629 = r102622 / r102628;
double r102630 = r102629 + r102621;
double r102631 = r102627 / r102630;
double r102632 = r102626 - r102631;
return r102632;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 25.6 |
|---|---|
| Target | 0.4 |
| Herbie | 3.3 |
Initial program 25.6
rmApplied div-sub25.6
Simplified24.1
Taylor expanded around 0 17.2
Simplified17.2
rmApplied *-un-lft-identity17.2
Applied *-un-lft-identity17.2
Applied distribute-lft-out--17.2
Simplified13.8
Taylor expanded around 0 5.3
Simplified3.3
Final simplification3.3
herbie shell --seed 2019194
(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))))