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



Bits error versus g



Bits error versus h



Bits error versus a
Results
if g < 1.7494555242604437e-220Initial program 36.5
rmApplied associate-*l/36.5
Applied cbrt-div33.1
Taylor expanded around -inf 32.3
if 1.7494555242604437e-220 < g Initial program 34.6
rmApplied associate-*l/34.6
Applied cbrt-div34.5
rmApplied cbrt-prod30.9
Taylor expanded around inf 31.1
Final simplification31.7
herbie shell --seed 2020056
(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))))))))