\frac{\cos th}{\sqrt{2}} \cdot \left(a1 \cdot a1\right) + \frac{\cos th}{\sqrt{2}} \cdot \left(a2 \cdot a2\right)\left(\cos th \cdot \mathsf{hypot}\left(a2, a1\right)\right) \cdot \frac{\mathsf{hypot}\left(a2, a1\right)}{\sqrt{2}}double f(double a1, double a2, double th) {
double r3103801 = th;
double r3103802 = cos(r3103801);
double r3103803 = 2.0;
double r3103804 = sqrt(r3103803);
double r3103805 = r3103802 / r3103804;
double r3103806 = a1;
double r3103807 = r3103806 * r3103806;
double r3103808 = r3103805 * r3103807;
double r3103809 = a2;
double r3103810 = r3103809 * r3103809;
double r3103811 = r3103805 * r3103810;
double r3103812 = r3103808 + r3103811;
return r3103812;
}
double f(double a1, double a2, double th) {
double r3103813 = th;
double r3103814 = cos(r3103813);
double r3103815 = a2;
double r3103816 = a1;
double r3103817 = hypot(r3103815, r3103816);
double r3103818 = r3103814 * r3103817;
double r3103819 = 2.0;
double r3103820 = sqrt(r3103819);
double r3103821 = r3103817 / r3103820;
double r3103822 = r3103818 * r3103821;
return r3103822;
}



Bits error versus a1



Bits error versus a2



Bits error versus th
Results
Initial program 0.5
Simplified0.5
rmApplied associate-/l*0.5
rmApplied *-un-lft-identity0.5
Applied *-un-lft-identity0.5
Applied sqrt-prod0.5
Applied times-frac0.5
Applied add-sqr-sqrt0.5
Applied times-frac0.5
Simplified0.5
Simplified0.5
rmApplied associate-*r*0.4
Final simplification0.4
herbie shell --seed 2019200 +o rules:numerics
(FPCore (a1 a2 th)
:name "Migdal et al, Equation (64)"
(+ (* (/ (cos th) (sqrt 2.0)) (* a1 a1)) (* (/ (cos th) (sqrt 2.0)) (* a2 a2))))