\frac{\cos th}{\sqrt{2}} \cdot \left(a1 \cdot a1\right) + \frac{\cos th}{\sqrt{2}} \cdot \left(a2 \cdot a2\right)\frac{\mathsf{hypot}\left(a2, a1\right) \cdot \cos th}{\sqrt{\frac{2}{\mathsf{fma}\left(a2, a2, a1 \cdot a1\right)}}}double f(double a1, double a2, double th) {
double r54688 = th;
double r54689 = cos(r54688);
double r54690 = 2.0;
double r54691 = sqrt(r54690);
double r54692 = r54689 / r54691;
double r54693 = a1;
double r54694 = r54693 * r54693;
double r54695 = r54692 * r54694;
double r54696 = a2;
double r54697 = r54696 * r54696;
double r54698 = r54692 * r54697;
double r54699 = r54695 + r54698;
return r54699;
}
double f(double a1, double a2, double th) {
double r54700 = a2;
double r54701 = a1;
double r54702 = hypot(r54700, r54701);
double r54703 = th;
double r54704 = cos(r54703);
double r54705 = r54702 * r54704;
double r54706 = 2.0;
double r54707 = r54701 * r54701;
double r54708 = fma(r54700, r54700, r54707);
double r54709 = r54706 / r54708;
double r54710 = sqrt(r54709);
double r54711 = r54705 / r54710;
return r54711;
}



Bits error versus a1



Bits error versus a2



Bits error versus th
Initial program 0.5
Simplified0.5
rmApplied add-sqr-sqrt0.5
Applied associate-*r*0.5
Simplified0.5
rmApplied associate-/l*0.5
Simplified0.4
rmApplied hypot-udef0.5
Applied sqrt-undiv0.7
Simplified0.7
Final simplification0.7
herbie shell --seed 2019322 +o rules:numerics
(FPCore (a1 a2 th)
:name "Migdal et al, Equation (64)"
:precision binary64
(+ (* (/ (cos th) (sqrt 2)) (* a1 a1)) (* (/ (cos th) (sqrt 2)) (* a2 a2))))