\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}
t_0 := \sqrt{g \cdot g - h \cdot h} - g\\
\mathbf{if}\;g \leq -2.893269831035563 \cdot 10^{-182}:\\
\;\;\;\;\frac{\sqrt[3]{t_0}}{\sqrt[3]{2 \cdot a}} + \sqrt[3]{\frac{g + \left(0.5 \cdot \frac{h \cdot h}{g} - g\right)}{a} \cdot -0.5}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{\frac{t_0}{2 \cdot a}} + \frac{\sqrt[3]{-0.5 \cdot \left(g + g\right)}}{\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
(let* ((t_0 (- (sqrt (- (* g g) (* h h))) g)))
(if (<= g -2.893269831035563e-182)
(+
(/ (cbrt t_0) (cbrt (* 2.0 a)))
(cbrt (* (/ (+ g (- (* 0.5 (/ (* h h) g)) g)) a) -0.5)))
(+ (cbrt (/ t_0 (* 2.0 a))) (/ (cbrt (* -0.5 (+ g g))) (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 t_0 = sqrt((g * g) - (h * h)) - g;
double tmp;
if (g <= -2.893269831035563e-182) {
tmp = (cbrt(t_0) / cbrt(2.0 * a)) + cbrt(((g + ((0.5 * ((h * h) / g)) - g)) / a) * -0.5);
} else {
tmp = cbrt(t_0 / (2.0 * a)) + (cbrt(-0.5 * (g + g)) / cbrt(a));
}
return tmp;
}



Bits error versus g



Bits error versus h



Bits error versus a
Results
if g < -2.8932698310355632e-182Initial program 34.9
Simplified34.9
Applied cbrt-div_binary6431.3
Taylor expanded in g around -inf 31.3
Simplified31.3
if -2.8932698310355632e-182 < g Initial program 37.4
Simplified37.4
Applied associate-*l/_binary6437.4
Applied cbrt-div_binary6433.6
Taylor expanded in g around inf 32.6
Final simplification32.0
herbie shell --seed 2021224
(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))))))))