\sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) + \sqrt{g \cdot g - h \cdot h}\right)} + \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) - \sqrt{g \cdot g - h \cdot h}\right)}\begin{array}{l}
\mathbf{if}\;g \le -6.77984610763763074 \cdot 10^{-172}:\\
\;\;\;\;\sqrt[3]{\frac{1}{2 \cdot a}} \cdot \sqrt[3]{\left(-g\right) + \sqrt{g \cdot g - h \cdot h}} + \sqrt[3]{\frac{1}{2 \cdot a}} \cdot \sqrt[3]{\frac{{h}^{2}}{\sqrt{g \cdot g - h \cdot h} - g}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) + \sqrt{g \cdot g - h \cdot h}\right)} + \sqrt[3]{\frac{1}{2 \cdot a}} \cdot \sqrt[3]{\left(-g\right) - g}\\
\end{array}double code(double g, double h, double a) {
return (cbrt(((1.0 / (2.0 * a)) * (-g + sqrt(((g * g) - (h * h)))))) + cbrt(((1.0 / (2.0 * a)) * (-g - sqrt(((g * g) - (h * h)))))));
}
double code(double g, double h, double a) {
double temp;
if ((g <= -6.779846107637631e-172)) {
temp = ((cbrt((1.0 / (2.0 * a))) * cbrt((-g + sqrt(((g * g) - (h * h)))))) + (cbrt((1.0 / (2.0 * a))) * cbrt((pow(h, 2.0) / (sqrt(((g * g) - (h * h))) - g)))));
} else {
temp = (cbrt(((1.0 / (2.0 * a)) * (-g + sqrt(((g * g) - (h * h)))))) + (cbrt((1.0 / (2.0 * a))) * cbrt((-g - g))));
}
return temp;
}



Bits error versus g



Bits error versus h



Bits error versus a
Results
if g < -6.779846107637631e-172Initial program 35.5
rmApplied cbrt-prod35.4
rmApplied cbrt-prod31.9
rmApplied flip--31.7
Simplified31.2
Simplified31.2
if -6.779846107637631e-172 < g Initial program 37.0
rmApplied cbrt-prod33.1
Taylor expanded around inf 32.1
Final simplification31.6
herbie shell --seed 2020066
(FPCore (g h a)
:name "2-ancestry mixing, positive discriminant"
:precision binary64
(+ (cbrt (* (/ 1 (* 2 a)) (+ (- g) (sqrt (- (* g g) (* h h)))))) (cbrt (* (/ 1 (* 2 a)) (- (- g) (sqrt (- (* g g) (* h h))))))))