\frac{\cos th}{\sqrt{2}} \cdot \left(a1 \cdot a1\right) + \frac{\cos th}{\sqrt{2}} \cdot \left(a2 \cdot a2\right)\left(\mathsf{hypot}\left(a1, a2\right) \cdot \cos th\right) \cdot \frac{\mathsf{hypot}\left(a1, a2\right)}{\sqrt{2}}double f(double a1, double a2, double th) {
double r76051 = th;
double r76052 = cos(r76051);
double r76053 = 2.0;
double r76054 = sqrt(r76053);
double r76055 = r76052 / r76054;
double r76056 = a1;
double r76057 = r76056 * r76056;
double r76058 = r76055 * r76057;
double r76059 = a2;
double r76060 = r76059 * r76059;
double r76061 = r76055 * r76060;
double r76062 = r76058 + r76061;
return r76062;
}
double f(double a1, double a2, double th) {
double r76063 = a1;
double r76064 = a2;
double r76065 = hypot(r76063, r76064);
double r76066 = th;
double r76067 = cos(r76066);
double r76068 = r76065 * r76067;
double r76069 = 2.0;
double r76070 = sqrt(r76069);
double r76071 = r76065 / r76070;
double r76072 = r76068 * r76071;
return r76072;
}



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.5
rmApplied *-commutative0.5
Final simplification0.5
herbie shell --seed 2020046 +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))))