\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\frac{b}{c + \frac{d}{\frac{c}{d}}} - \frac{a}{d + c \cdot \frac{c}{d}}double f(double a, double b, double c, double d) {
double r83630 = b;
double r83631 = c;
double r83632 = r83630 * r83631;
double r83633 = a;
double r83634 = d;
double r83635 = r83633 * r83634;
double r83636 = r83632 - r83635;
double r83637 = r83631 * r83631;
double r83638 = r83634 * r83634;
double r83639 = r83637 + r83638;
double r83640 = r83636 / r83639;
return r83640;
}
double f(double a, double b, double c, double d) {
double r83641 = b;
double r83642 = c;
double r83643 = d;
double r83644 = r83642 / r83643;
double r83645 = r83643 / r83644;
double r83646 = r83642 + r83645;
double r83647 = r83641 / r83646;
double r83648 = a;
double r83649 = r83642 * r83644;
double r83650 = r83643 + r83649;
double r83651 = r83648 / r83650;
double r83652 = r83647 - r83651;
return r83652;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.1 |
|---|---|
| Target | 0.4 |
| Herbie | 3.3 |
Initial program 26.1
rmApplied div-sub26.1
Simplified24.4
Simplified22.9
Taylor expanded around 0 15.6
Simplified14.1
Taylor expanded around 0 5.5
Simplified3.3
rmApplied associate-/r/3.3
Final simplification3.3
herbie shell --seed 2019179
(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))))