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



Bits error versus g



Bits error versus h



Bits error versus a
Results
if g < 3.5006831600779324e-240Initial program 36.5
rmApplied associate-*l/_binary6436.5
Applied cbrt-div_binary6432.3
Simplified32.3
Taylor expanded around -inf 31.5
Simplified31.5
if 3.5006831600779324e-240 < g Initial program 35.2
rmApplied associate-*l/_binary6435.2
Applied cbrt-div_binary6431.1
Simplified31.1
rmApplied add-sqr-sqrt_binary6431.1
Applied sqrt-prod_binary6431.1
Final simplification31.3
herbie shell --seed 2020231
(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))))))))