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



Bits error versus g



Bits error versus h



Bits error versus a
Results
if g < -9.7586871394713417e-159Initial program 34.5
Simplified34.5
Applied cbrt-div_binary6430.9
Taylor expanded in g around -inf 30.4
Simplified30.4
if -9.7586871394713417e-159 < g Initial program 37.0
Simplified37.0
Applied associate-*l/_binary6437.0
Applied cbrt-div_binary6433.4
Taylor expanded in g around inf 32.0
Final simplification31.3
herbie shell --seed 2022039
(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))))))))