\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 \leq 9.47105339365848 \cdot 10^{-158}:\\
\;\;\;\;\sqrt[3]{g \cdot -2} \cdot \sqrt[3]{\frac{0.5}{a}} + \sqrt[3]{\frac{g + \sqrt{g \cdot g - h \cdot h}}{a} \cdot -0.5}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{\frac{\frac{-h \cdot h}{g + \sqrt{g \cdot g - h \cdot h}}}{a \cdot 2}} + \frac{\sqrt[3]{\left(g + \sqrt{g \cdot g - h \cdot h}\right) \cdot -0.5}}{\sqrt[3]{a}}\\
\end{array}(FPCore (g h a) :precision binary64 (+ (cbrt (* (/ 1.0 (* 2.0 a)) (+ (- g) (sqrt (- (* g g) (* h h)))))) (cbrt (* (/ 1.0 (* 2.0 a)) (- (- g) (sqrt (- (* g g) (* h h))))))))
(FPCore (g h a)
:precision binary64
(if (<= g 9.47105339365848e-158)
(+
(* (cbrt (* g -2.0)) (cbrt (/ 0.5 a)))
(cbrt (* (/ (+ g (sqrt (- (* g g) (* h h)))) a) -0.5)))
(+
(cbrt (/ (/ (- (* h h)) (+ g (sqrt (- (* g g) (* h h))))) (* a 2.0)))
(/ (cbrt (* (+ g (sqrt (- (* g g) (* h h)))) -0.5)) (cbrt a)))))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 tmp;
if (g <= 9.47105339365848e-158) {
tmp = (cbrt(g * -2.0) * cbrt(0.5 / a)) + cbrt(((g + sqrt((g * g) - (h * h))) / a) * -0.5);
} else {
tmp = cbrt((-(h * h) / (g + sqrt((g * g) - (h * h)))) / (a * 2.0)) + (cbrt((g + sqrt((g * g) - (h * h))) * -0.5) / cbrt(a));
}
return tmp;
}



Bits error versus g



Bits error versus h



Bits error versus a
Results
if g < 9.47105339365848073e-158Initial program 36.7
Simplified36.6
rmApplied div-inv_binary64_621336.7
Applied cbrt-prod_binary64_624733.1
Simplified33.0
Taylor expanded around -inf 31.7
Simplified31.7
if 9.47105339365848073e-158 < g Initial program 34.7
Simplified34.7
rmApplied associate-*l/_binary64_615934.7
Applied cbrt-div_binary64_624831.1
Simplified31.1
rmApplied flip--_binary64_619131.1
Simplified30.6
Simplified30.6
Final simplification31.2
herbie shell --seed 2021064
(FPCore (g h a)
:name "2-ancestry mixing, positive discriminant"
:precision binary64
(+ (cbrt (* (/ 1.0 (* 2.0 a)) (+ (- g) (sqrt (- (* g g) (* h h)))))) (cbrt (* (/ 1.0 (* 2.0 a)) (- (- g) (sqrt (- (* g g) (* h h))))))))