\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 -3.5033303319024632 \cdot 10^{-160} \lor \neg \left(g \le 5.5317065960389481 \cdot 10^{-148}\right):\\
\;\;\;\;\sqrt[3]{\left(-g\right) + \sqrt{g \cdot g - h \cdot h}} \cdot \sqrt[3]{\frac{1}{2 \cdot a}} + \sqrt[3]{\left(-g\right) - \sqrt{g \cdot g - h \cdot h}} \cdot \sqrt[3]{\frac{1}{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)} + \sqrt[3]{\left(-g\right) - g} \cdot \sqrt[3]{\frac{1}{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 VAR;
if (((g <= -3.503330331902463e-160) || !(g <= 5.531706596038948e-148))) {
VAR = ((cbrt((-g + sqrt(((g * g) - (h * h))))) * cbrt((1.0 / (2.0 * a)))) + (cbrt((-g - sqrt(((g * g) - (h * h))))) * cbrt((1.0 / (2.0 * a)))));
} else {
VAR = (cbrt(((1.0 / (2.0 * a)) * (-g + sqrt(((g * g) - (h * h)))))) + (cbrt((-g - g)) * cbrt((1.0 / (2.0 * a)))));
}
return VAR;
}



Bits error versus g



Bits error versus h



Bits error versus a
Results
if g < -3.503330331902463e-160 or 5.531706596038948e-148 < g Initial program 35.0
rmApplied *-commutative35.0
Applied cbrt-prod33.0
rmApplied *-commutative33.0
Applied cbrt-prod31.0
if -3.503330331902463e-160 < g < 5.531706596038948e-148Initial program 51.6
rmApplied *-commutative51.6
Applied cbrt-prod47.6
Taylor expanded around inf 35.2
Final simplification31.3
herbie shell --seed 2020071
(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))))))))