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



Bits error versus g



Bits error versus h



Bits error versus a
Results
if (+.f64 (cbrt.f64 (*.f64 (/.f64 1 (*.f64 2 a)) (+.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h)))))) (cbrt.f64 (*.f64 (/.f64 1 (*.f64 2 a)) (-.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h))))))) < -7.8133694899696849e-106Initial program 10.0
rmApplied cbrt-prod_binary64_59067.9
Simplified7.9
rmApplied cbrt-prod_binary64_59065.5
Simplified5.5
Simplified5.5
if -7.8133694899696849e-106 < (+.f64 (cbrt.f64 (*.f64 (/.f64 1 (*.f64 2 a)) (+.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h)))))) (cbrt.f64 (*.f64 (/.f64 1 (*.f64 2 a)) (-.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h))))))) < 0.0Initial program 60.5
rmApplied associate-*l/_binary64_581860.5
Applied cbrt-div_binary64_590739.1
Simplified39.1
Taylor expanded around -inf 6.8
Simplified6.8
if 0.0 < (+.f64 (cbrt.f64 (*.f64 (/.f64 1 (*.f64 2 a)) (+.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h)))))) (cbrt.f64 (*.f64 (/.f64 1 (*.f64 2 a)) (-.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h))))))) Initial program 44.1
rmApplied associate-*l/_binary64_581844.1
Applied cbrt-div_binary64_590743.3
Simplified43.3
Final simplification32.2
herbie shell --seed 2020357
(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))))))))