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



Bits error versus g



Bits error versus h



Bits error versus a
Results
if g < -1.9660266893741359e-164Initial program 35.0
rmApplied associate-*l/_binary6435.0
Applied cbrt-div_binary6435.0
Simplified35.0
rmApplied cbrt-prod_binary6430.7
Simplified30.7
Simplified30.7
rmApplied add-cube-cbrt_binary6430.7
Applied sqrt-prod_binary6430.7
Simplified30.7
if -1.9660266893741359e-164 < g Initial program 37.4
rmApplied associate-*l/_binary6437.4
Applied cbrt-div_binary6433.4
Simplified33.4
Taylor expanded around inf 32.2
Final simplification31.5
herbie shell --seed 2020253
(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))))))))