\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}double f(double a, double b, double c, double d) {
double r4133589 = a;
double r4133590 = c;
double r4133591 = r4133589 * r4133590;
double r4133592 = b;
double r4133593 = d;
double r4133594 = r4133592 * r4133593;
double r4133595 = r4133591 + r4133594;
double r4133596 = r4133590 * r4133590;
double r4133597 = r4133593 * r4133593;
double r4133598 = r4133596 + r4133597;
double r4133599 = r4133595 / r4133598;
return r4133599;
}
double f(double a, double b, double c, double d) {
double r4133600 = a;
double r4133601 = c;
double r4133602 = b;
double r4133603 = d;
double r4133604 = r4133602 * r4133603;
double r4133605 = fma(r4133600, r4133601, r4133604);
double r4133606 = r4133601 * r4133601;
double r4133607 = fma(r4133603, r4133603, r4133606);
double r4133608 = r4133605 / r4133607;
return r4133608;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
| Original | 25.8 |
|---|---|
| Target | 0.4 |
| Herbie | 25.8 |
Initial program 25.8
Simplified25.8
Final simplification25.8
herbie shell --seed 2019163 +o rules:numerics
(FPCore (a b c d)
:name "Complex division, real part"
: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))))