2 \cdot \cos \left(\frac{2 \cdot \pi}{3} + \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right)2 \cdot \left(\cos \left(\frac{2 \cdot \pi}{3} + \frac{\pi}{3}\right) \cdot \cos \left(\frac{\cos^{-1} \left(\frac{g}{h}\right)}{3}\right) + \sin \left(\frac{2 \cdot \pi}{3} + \frac{\pi}{3}\right) \cdot \sin \left(\frac{\cos^{-1} \left(\frac{g}{h}\right)}{3}\right)\right)double code(double g, double h) {
return (2.0 * cos((((2.0 * ((double) M_PI)) / 3.0) + (acos((-g / h)) / 3.0))));
}
double code(double g, double h) {
return (2.0 * ((cos((((2.0 * ((double) M_PI)) / 3.0) + (((double) M_PI) / 3.0))) * cos((acos((g / h)) / 3.0))) + (sin((((2.0 * ((double) M_PI)) / 3.0) + (((double) M_PI) / 3.0))) * sin((acos((g / h)) / 3.0)))));
}



Bits error versus g



Bits error versus h
Results
Initial program 1.0
rmApplied distribute-frac-neg1.0
Applied acos-neg1.0
Applied div-sub1.0
Applied associate-+r-1.0
Applied cos-diff0.0
Final simplification0.0
herbie shell --seed 2020057 +o rules:numerics
(FPCore (g h)
:name "2-ancestry mixing, negative discriminant"
:precision binary64
(* 2 (cos (+ (/ (* 2 PI) 3) (/ (acos (/ (- g) h)) 3)))))