\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 -1.0451968344146333 \cdot 10^{-104}:\\
\;\;\;\;\sqrt[3]{\left(\sqrt{g \cdot g - h \cdot h} - g\right) \cdot \frac{0.5}{a}} + \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]{\frac{1}{2 \cdot a} \cdot \left(\sqrt{g \cdot g - h \cdot h} - g\right)} + \sqrt[3]{\frac{0.5}{a}} \cdot \sqrt[3]{\left(-g\right) - g}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{\frac{0.5}{a}} \cdot \sqrt[3]{\left(-g\right) - \sqrt{g \cdot g - h \cdot h}} + \sqrt[3]{\frac{0.5}{a}} \cdot \sqrt[3]{\sqrt{g \cdot g - h \cdot h} - g}\\
\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)))))
-1.0451968344146333e-104)
(+
(cbrt (* (- (sqrt (- (* g g) (* h h))) g) (/ 0.5 a)))
(* (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 (* (/ 1.0 (* 2.0 a)) (- (sqrt (- (* g g) (* h h))) g)))
(* (cbrt (/ 0.5 a)) (cbrt (- (- g) g))))
(+
(* (cbrt (/ 0.5 a)) (cbrt (- (- g) (sqrt (- (* g g) (* h h))))))
(* (cbrt (/ 0.5 a)) (cbrt (- (sqrt (- (* g g) (* h h))) g)))))))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)))) <= -1.0451968344146333e-104) {
tmp = cbrt((sqrt((g * g) - (h * h)) - g) * (0.5 / a)) + (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((1.0 / (2.0 * a)) * (sqrt((g * g) - (h * h)) - g)) + (cbrt(0.5 / a) * cbrt(-g - g));
} else {
tmp = (cbrt(0.5 / a) * cbrt(-g - sqrt((g * g) - (h * h)))) + (cbrt(0.5 / a) * cbrt(sqrt((g * g) - (h * h)) - g));
}
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))))))) < -1.0451968344146333e-104Initial program 10.0
rmApplied cbrt-prod_binary64_18147.7
Simplified7.7
rmApplied add-cbrt-cube_binary64_18197.8
Simplified7.7
if -1.0451968344146333e-104 < (+.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.0
rmApplied cbrt-prod_binary64_181439.8
Simplified39.5
Taylor expanded around inf 6.0
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 43.9
rmApplied cbrt-prod_binary64_181443.0
Simplified43.0
rmApplied cbrt-prod_binary64_181442.1
Simplified42.1
Simplified42.1
Final simplification31.7
herbie shell --seed 2020315
(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))))))))