\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 -7.7225920010437145 \cdot 10^{-180}:\\
\;\;\;\;\sqrt[3]{\frac{1}{2 \cdot a}} \cdot \sqrt[3]{\left(-g\right) + \left(\sqrt[3]{\sqrt{g \cdot g - h \cdot h}} \cdot \sqrt[3]{\sqrt{g \cdot g - h \cdot h}}\right) \cdot \sqrt[3]{\sqrt{g \cdot g - h \cdot h}}} + \frac{\sqrt[3]{1 \cdot \left(\left(-g\right) - \sqrt{g \cdot g - h \cdot h}\right)}}{\sqrt[3]{2 \cdot a}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) + \sqrt{g \cdot g - h \cdot h}\right)} + \frac{\sqrt[3]{1 \cdot \left(\left(-g\right) - g\right)}}{\sqrt[3]{2 \cdot a}}\\
\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 <= -7.722592001043715e-180)) {
temp = ((cbrt((1.0 / (2.0 * a))) * cbrt((-g + ((cbrt(sqrt(((g * g) - (h * h)))) * cbrt(sqrt(((g * g) - (h * h))))) * cbrt(sqrt(((g * g) - (h * h)))))))) + (cbrt((1.0 * (-g - sqrt(((g * g) - (h * h)))))) / cbrt((2.0 * a))));
} else {
temp = (cbrt(((1.0 / (2.0 * a)) * (-g + sqrt(((g * g) - (h * h)))))) + (cbrt((1.0 * (-g - g))) / cbrt((2.0 * a))));
}
return temp;
}



Bits error versus g



Bits error versus h



Bits error versus a
Results
if g < -7.722592001043715e-180Initial program 35.4
rmApplied associate-*l/35.4
Applied cbrt-div35.3
rmApplied cbrt-prod31.9
rmApplied add-cube-cbrt31.9
if -7.722592001043715e-180 < g Initial program 37.1
rmApplied associate-*l/37.1
Applied cbrt-div33.4
Taylor expanded around inf 32.2
Final simplification32.0
herbie shell --seed 2020058 +o rules:numerics
(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))))))))