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



Bits error versus g



Bits error versus h



Bits error versus a
Results
if g < -3.3224493514689172e-214Initial program 36.4
Simplified36.4
rmApplied associate-*l/_binary64_240836.4
Applied cbrt-div_binary64_249736.3
rmApplied difference-of-squares_binary64_243436.3
rmApplied cbrt-div_binary64_249732.3
rmApplied flip-+_binary64_243932.2
Simplified31.5
Simplified31.5
if -3.3224493514689172e-214 < g < 7.69250790700328266e92Initial program 16.4
Simplified16.4
rmApplied associate-*l/_binary64_240816.4
Applied cbrt-div_binary64_249711.2
Taylor expanded around inf 8.9
if 7.69250790700328266e92 < g Initial program 52.6
Simplified52.6
rmApplied associate-*l/_binary64_240852.6
Applied cbrt-div_binary64_249749.6
rmApplied difference-of-squares_binary64_243449.6
rmApplied cbrt-div_binary64_249749.6
rmApplied add-sqr-sqrt_binary64_248749.6
Simplified49.6
Simplified49.6
Final simplification31.5
herbie shell --seed 2020298
(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))))))))