\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 r102573 = th;
double r102574 = cos(r102573);
double r102575 = 2.0;
double r102576 = sqrt(r102575);
double r102577 = r102574 / r102576;
double r102578 = a1;
double r102579 = r102578 * r102578;
double r102580 = r102577 * r102579;
double r102581 = a2;
double r102582 = r102581 * r102581;
double r102583 = r102577 * r102582;
double r102584 = r102580 + r102583;
return r102584;
}
double f(double a1, double a2, double th) {
double r102585 = th;
double r102586 = cos(r102585);
double r102587 = a1;
double r102588 = a2;
double r102589 = hypot(r102587, r102588);
double r102590 = r102586 * r102589;
double r102591 = r102587 * r102587;
double r102592 = r102588 * r102588;
double r102593 = r102591 + r102592;
double r102594 = 2.0;
double r102595 = r102593 / r102594;
double r102596 = sqrt(r102595);
double r102597 = r102590 * r102596;
return r102597;
}



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