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



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