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



Bits error versus g



Bits error versus h



Bits error versus a
Results
if g < -5.91307306101582669e-182Initial program 34.7
rmApplied associate-*l/_binary64_339234.7
Applied cbrt-div_binary64_347634.7
Simplified34.7
rmApplied associate-*l/_binary64_339234.7
Applied cbrt-div_binary64_347630.9
Simplified30.9
rmApplied add-cube-cbrt_binary64_347930.9
Applied sqrt-prod_binary64_346230.9
Simplified30.9
if -5.91307306101582669e-182 < g Initial program 35.4
rmApplied associate-*l/_binary64_339235.4
Applied cbrt-div_binary64_347632.0
Simplified32.0
Taylor expanded around inf 31.0
Final simplification31.0
herbie shell --seed 2020281
(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))))))))