\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 r3103203 = th;
double r3103204 = cos(r3103203);
double r3103205 = 2.0;
double r3103206 = sqrt(r3103205);
double r3103207 = r3103204 / r3103206;
double r3103208 = a1;
double r3103209 = r3103208 * r3103208;
double r3103210 = r3103207 * r3103209;
double r3103211 = a2;
double r3103212 = r3103211 * r3103211;
double r3103213 = r3103207 * r3103212;
double r3103214 = r3103210 + r3103213;
return r3103214;
}
double f(double a1, double a2, double th) {
double r3103215 = th;
double r3103216 = cos(r3103215);
double r3103217 = a2;
double r3103218 = a1;
double r3103219 = hypot(r3103217, r3103218);
double r3103220 = r3103216 * r3103219;
double r3103221 = 2.0;
double r3103222 = sqrt(r3103221);
double r3103223 = r3103219 / r3103222;
double r3103224 = r3103220 * r3103223;
return r3103224;
}



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))))