\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 := \sqrt[3]{\left(g + t_0\right) \cdot \frac{-1}{a \cdot 2}}\\
t_2 := \sqrt[3]{\frac{0.5}{a}}\\
\mathbf{if}\;g \leq 8.577312417414274 \cdot 10^{-162}:\\
\;\;\;\;t_2 \cdot \sqrt[3]{\left(0.5 \cdot \frac{h \cdot h}{g} - g\right) - g} + t_1\\
\mathbf{elif}\;g \leq 7.483790593490912 \cdot 10^{+24}:\\
\;\;\;\;t_1 + \frac{\sqrt[3]{-0.5 \cdot \frac{{h}^{2}}{g}}}{\sqrt[3]{a \cdot 2}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{\frac{1}{a \cdot 2} \cdot \left(t_0 - g\right)} + t_2 \cdot \sqrt[3]{\left(-g\right) - t_0}\\
\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 (cbrt (* (+ g t_0) (/ -1.0 (* a 2.0)))))
(t_2 (cbrt (/ 0.5 a))))
(if (<= g 8.577312417414274e-162)
(+ (* t_2 (cbrt (- (- (* 0.5 (/ (* h h) g)) g) g))) t_1)
(if (<= g 7.483790593490912e+24)
(+ t_1 (/ (cbrt (* -0.5 (/ (pow h 2.0) g))) (cbrt (* a 2.0))))
(+
(cbrt (* (/ 1.0 (* a 2.0)) (- t_0 g)))
(* t_2 (cbrt (- (- g) t_0))))))))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 = cbrt((g + t_0) * (-1.0 / (a * 2.0)));
double t_2 = cbrt(0.5 / a);
double tmp;
if (g <= 8.577312417414274e-162) {
tmp = (t_2 * cbrt(((0.5 * ((h * h) / g)) - g) - g)) + t_1;
} else if (g <= 7.483790593490912e+24) {
tmp = t_1 + (cbrt(-0.5 * (pow(h, 2.0) / g)) / cbrt(a * 2.0));
} else {
tmp = cbrt((1.0 / (a * 2.0)) * (t_0 - g)) + (t_2 * cbrt(-g - t_0));
}
return tmp;
}



Bits error versus g



Bits error versus h



Bits error versus a
Results
if g < 8.57731241741427389e-162Initial program 36.8
Applied cbrt-prod_binary6433.2
Simplified33.1
Simplified33.1
Taylor expanded in g around -inf 31.9
Simplified31.9
if 8.57731241741427389e-162 < g < 7.483790593490912e24Initial program 6.5
Applied associate-*l/_binary646.5
Applied cbrt-div_binary646.5
Simplified6.5
Taylor expanded in g around inf 5.4
if 7.483790593490912e24 < g Initial program 43.7
Applied cbrt-prod_binary6439.7
Simplified39.7
Final simplification31.3
herbie shell --seed 2022055
(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))))))))