\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}
\mathbf{if}\;g \leq 3.1405143144072282 \cdot 10^{-183}:\\
\;\;\;\;\left(\sqrt[3]{g \cdot -2} \cdot \sqrt[3]{\frac{-1}{a}}\right) \cdot \sqrt[3]{-0.5} + \sqrt[3]{\left(g + \sqrt{g \cdot g - h \cdot h}\right) \cdot \frac{-1}{a \cdot 2}}\\
\mathbf{elif}\;g \leq 7.721957821369504 \cdot 10^{+69}:\\
\;\;\;\;\sqrt[3]{\left(g + \sqrt{g \cdot g - h \cdot h}\right) \cdot \frac{-1}{a \cdot 2}} + \frac{\sqrt[3]{0.5 \cdot \frac{h \cdot h}{a}}}{\sqrt[3]{\left(-g\right) - \sqrt{g \cdot g - h \cdot h}}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{\frac{1}{a \cdot 2} \cdot \left(\sqrt{g \cdot g - h \cdot h} - g\right)} + \frac{\sqrt[3]{\left(-g\right) - \sqrt{g \cdot g - h \cdot h}}}{\sqrt[3]{a \cdot 2}}\\
\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
(if (<= g 3.1405143144072282e-183)
(+
(* (* (cbrt (* g -2.0)) (cbrt (/ -1.0 a))) (cbrt -0.5))
(cbrt (* (+ g (sqrt (- (* g g) (* h h)))) (/ -1.0 (* a 2.0)))))
(if (<= g 7.721957821369504e+69)
(+
(cbrt (* (+ g (sqrt (- (* g g) (* h h)))) (/ -1.0 (* a 2.0))))
(/
(cbrt (* 0.5 (/ (* h h) a)))
(cbrt (- (- g) (sqrt (- (* g g) (* h h)))))))
(+
(cbrt (* (/ 1.0 (* a 2.0)) (- (sqrt (- (* g g) (* h h))) g)))
(/ (cbrt (- (- g) (sqrt (- (* g g) (* h h))))) (cbrt (* a 2.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 tmp;
if (g <= 3.1405143144072282e-183) {
tmp = ((cbrt(g * -2.0) * cbrt(-1.0 / a)) * cbrt(-0.5)) + cbrt((g + sqrt((g * g) - (h * h))) * (-1.0 / (a * 2.0)));
} else if (g <= 7.721957821369504e+69) {
tmp = cbrt((g + sqrt((g * g) - (h * h))) * (-1.0 / (a * 2.0))) + (cbrt(0.5 * ((h * h) / a)) / cbrt(-g - sqrt((g * g) - (h * h))));
} else {
tmp = cbrt((1.0 / (a * 2.0)) * (sqrt((g * g) - (h * h)) - g)) + (cbrt(-g - sqrt((g * g) - (h * h))) / cbrt(a * 2.0));
}
return tmp;
}



Bits error versus g



Bits error versus h



Bits error versus a
Results
if g < 3.1405143144072282e-183Initial program 36.3
Taylor expanded around -inf 49.6
Simplified32.8
Taylor expanded around -inf 31.7
if 3.1405143144072282e-183 < g < 7.7219578213695045e69Initial program 9.3
rmApplied flip-+_binary64_55089.0
Applied associate-*r/_binary64_54769.1
Applied cbrt-div_binary64_55669.1
Simplified8.0
if 7.7219578213695045e69 < g Initial program 48.2
rmApplied associate-*l/_binary64_547748.2
Applied cbrt-div_binary64_556644.9
Simplified44.9
Final simplification32.0
herbie shell --seed 2021045
(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))))))))