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



Bits error versus g



Bits error versus h



Bits error versus a
Results
if g < -9.4630072293780591e-247Initial program 35.7
Simplified35.7
Applied div-inv_binary6435.7
Applied cbrt-prod_binary6432.2
Simplified32.1
Taylor expanded in g around -inf 31.7
if -9.4630072293780591e-247 < g Initial program 35.7
Simplified35.7
Applied associate-*l/_binary6435.7
Applied cbrt-div_binary6432.3
Final simplification32.0
herbie shell --seed 2022020
(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))))))))