\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(a1, a2\right)\right) \cdot \sqrt{\frac{a1 \cdot a1 + a2 \cdot a2}{2}}double f(double a1, double a2, double th) {
double r102497 = th;
double r102498 = cos(r102497);
double r102499 = 2.0;
double r102500 = sqrt(r102499);
double r102501 = r102498 / r102500;
double r102502 = a1;
double r102503 = r102502 * r102502;
double r102504 = r102501 * r102503;
double r102505 = a2;
double r102506 = r102505 * r102505;
double r102507 = r102501 * r102506;
double r102508 = r102504 + r102507;
return r102508;
}
double f(double a1, double a2, double th) {
double r102509 = th;
double r102510 = cos(r102509);
double r102511 = a1;
double r102512 = a2;
double r102513 = hypot(r102511, r102512);
double r102514 = r102510 * r102513;
double r102515 = r102511 * r102511;
double r102516 = r102512 * r102512;
double r102517 = r102515 + r102516;
double r102518 = 2.0;
double r102519 = r102517 / r102518;
double r102520 = sqrt(r102519);
double r102521 = r102514 * r102520;
return r102521;
}



Bits error versus a1



Bits error versus a2



Bits error versus th
Results
Initial program 0.5
Simplified0.5
rmApplied add-sqr-sqrt0.5
Applied associate-*r*0.5
Simplified0.5
rmApplied *-un-lft-identity0.5
Applied sqrt-prod0.5
Applied times-frac0.5
Simplified0.5
Simplified0.4
rmApplied hypot-udef0.5
Applied sqrt-undiv0.4
Final simplification0.4
herbie shell --seed 2020001 +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))))