\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\frac{b \cdot c - d \cdot a}{\sqrt{(d \cdot d + \left(c \cdot c\right))_*}} \cdot \frac{1}{\sqrt{(d \cdot d + \left(c \cdot c\right))_*}}double f(double a, double b, double c, double d) {
double r31630557 = b;
double r31630558 = c;
double r31630559 = r31630557 * r31630558;
double r31630560 = a;
double r31630561 = d;
double r31630562 = r31630560 * r31630561;
double r31630563 = r31630559 - r31630562;
double r31630564 = r31630558 * r31630558;
double r31630565 = r31630561 * r31630561;
double r31630566 = r31630564 + r31630565;
double r31630567 = r31630563 / r31630566;
return r31630567;
}
double f(double a, double b, double c, double d) {
double r31630568 = b;
double r31630569 = c;
double r31630570 = r31630568 * r31630569;
double r31630571 = d;
double r31630572 = a;
double r31630573 = r31630571 * r31630572;
double r31630574 = r31630570 - r31630573;
double r31630575 = r31630569 * r31630569;
double r31630576 = fma(r31630571, r31630571, r31630575);
double r31630577 = sqrt(r31630576);
double r31630578 = r31630574 / r31630577;
double r31630579 = 1.0;
double r31630580 = r31630579 / r31630577;
double r31630581 = r31630578 * r31630580;
return r31630581;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
| Original | 25.6 |
|---|---|
| Target | 0.3 |
| Herbie | 25.7 |
Initial program 25.6
Simplified25.6
rmApplied add-sqr-sqrt25.7
Applied *-un-lft-identity25.7
Applied times-frac25.7
Final simplification25.7
herbie shell --seed 2019112 +o rules:numerics
(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))))