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



Bits error versus g



Bits error versus h



Bits error versus a
Results
if g < -4.2919345164350253e-290Initial program 35.4
Simplified35.4
Applied associate-*l/_binary6435.4
Applied cbrt-div_binary6435.2
Applied div-inv_binary6435.2
Applied cbrt-prod_binary6431.6
Simplified31.6
Taylor expanded in g around -inf 31.1
if -4.2919345164350253e-290 < g Initial program 35.5
Simplified35.5
Applied associate-*l/_binary6435.5
Applied cbrt-div_binary6431.4
Applied difference-of-squares_binary6431.4
Applied sqrt-prod_binary6430.6
Simplified30.6
Final simplification30.8
herbie shell --seed 2022094
(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))))))))