\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\frac{\frac{c}{c \cdot c + d \cdot d}}{\frac{1}{b}} - \frac{a}{d + \frac{c \cdot c}{d}}double f(double a, double b, double c, double d) {
double r4693423 = b;
double r4693424 = c;
double r4693425 = r4693423 * r4693424;
double r4693426 = a;
double r4693427 = d;
double r4693428 = r4693426 * r4693427;
double r4693429 = r4693425 - r4693428;
double r4693430 = r4693424 * r4693424;
double r4693431 = r4693427 * r4693427;
double r4693432 = r4693430 + r4693431;
double r4693433 = r4693429 / r4693432;
return r4693433;
}
double f(double a, double b, double c, double d) {
double r4693434 = c;
double r4693435 = r4693434 * r4693434;
double r4693436 = d;
double r4693437 = r4693436 * r4693436;
double r4693438 = r4693435 + r4693437;
double r4693439 = r4693434 / r4693438;
double r4693440 = 1.0;
double r4693441 = b;
double r4693442 = r4693440 / r4693441;
double r4693443 = r4693439 / r4693442;
double r4693444 = a;
double r4693445 = r4693435 / r4693436;
double r4693446 = r4693436 + r4693445;
double r4693447 = r4693444 / r4693446;
double r4693448 = r4693443 - r4693447;
return r4693448;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
Results
| Original | 26.2 |
|---|---|
| Target | 0.4 |
| Herbie | 15.8 |
Initial program 26.2
rmApplied add-sqr-sqrt26.2
Applied associate-/r*26.1
rmApplied div-sub26.1
Applied div-sub26.1
Simplified26.8
Simplified25.3
Taylor expanded around 0 17.9
Simplified17.9
rmApplied div-inv17.9
Applied associate-/r*15.8
Final simplification15.8
herbie shell --seed 2019169
(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))))