\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\frac{1}{\mathsf{fma}\left(d, d, \left(c \cdot c\right)\right)} \cdot \mathsf{fma}\left(a, c, \left(b \cdot d\right)\right)double f(double a, double b, double c, double d) {
double r22830887 = a;
double r22830888 = c;
double r22830889 = r22830887 * r22830888;
double r22830890 = b;
double r22830891 = d;
double r22830892 = r22830890 * r22830891;
double r22830893 = r22830889 + r22830892;
double r22830894 = r22830888 * r22830888;
double r22830895 = r22830891 * r22830891;
double r22830896 = r22830894 + r22830895;
double r22830897 = r22830893 / r22830896;
return r22830897;
}
double f(double a, double b, double c, double d) {
double r22830898 = 1.0;
double r22830899 = d;
double r22830900 = c;
double r22830901 = r22830900 * r22830900;
double r22830902 = fma(r22830899, r22830899, r22830901);
double r22830903 = r22830898 / r22830902;
double r22830904 = a;
double r22830905 = b;
double r22830906 = r22830905 * r22830899;
double r22830907 = fma(r22830904, r22830900, r22830906);
double r22830908 = r22830903 * r22830907;
return r22830908;
}




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus d
| Original | 25.3 |
|---|---|
| Target | 0.5 |
| Herbie | 25.5 |
Initial program 25.3
Simplified25.3
rmApplied div-inv25.5
Final simplification25.5
herbie shell --seed 2019125 +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))))