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



Bits error versus g



Bits error versus h



Bits error versus a
Results
if g < -7.0352854710562029e-159Initial program 33.9
Simplified33.9
rmApplied div-inv_binary64_246233.9
Applied cbrt-prod_binary64_249630.3
Simplified30.3
if -7.0352854710562029e-159 < g < 1.03735101238175904e-131Initial program 48.3
Simplified48.3
rmApplied associate-*l/_binary64_240848.3
Applied cbrt-div_binary64_249742.9
Taylor expanded around inf 32.1
if 1.03735101238175904e-131 < g Initial program 35.2
Simplified35.2
rmApplied associate-*l/_binary64_240835.2
Applied cbrt-div_binary64_249731.4
rmApplied add-cube-cbrt_binary64_250031.4
Applied times-frac_binary64_247131.4
Applied cbrt-prod_binary64_249631.4
Final simplification30.9
herbie shell --seed 2020343
(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))))))))