\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 -9.465563849143672 \cdot 10^{-106} \lor \neg \left(\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\right):\\
\;\;\;\;\sqrt[3]{\sqrt{g \cdot g - h \cdot h} - g} \cdot \sqrt[3]{\frac{0.5}{a}} + \left(\sqrt[3]{g + \sqrt{g \cdot g - h \cdot h}} \cdot \sqrt[3]{\frac{-1}{a}}\right) \cdot \sqrt[3]{0.5}\\
\mathbf{else}:\\
\;\;\;\;\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}}\\
\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 (or (<=
(+
(cbrt (* (/ 1.0 (* 2.0 a)) (- (sqrt (- (* g g) (* h h))) g)))
(cbrt (* (+ g (sqrt (- (* g g) (* h h)))) (/ -1.0 (* 2.0 a)))))
-9.465563849143672e-106)
(not
(<=
(+
(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 (- (sqrt (- (* g g) (* h h))) g)) (cbrt (/ 0.5 a)))
(*
(* (cbrt (+ g (sqrt (- (* g g) (* h h))))) (cbrt (/ -1.0 a)))
(cbrt 0.5)))
(+
(cbrt (/ (- (sqrt (- (* g g) (* h h))) g) (* 2.0 a)))
(/ (cbrt (* -0.5 (+ g g))) (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 (((cbrt((1.0 / (2.0 * a)) * (sqrt((g * g) - (h * h)) - g)) + cbrt((g + sqrt((g * g) - (h * h))) * (-1.0 / (2.0 * a)))) <= -9.465563849143672e-106) || !((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(sqrt((g * g) - (h * h)) - g) * cbrt(0.5 / a)) + ((cbrt(g + sqrt((g * g) - (h * h))) * cbrt(-1.0 / a)) * cbrt(0.5));
} else {
tmp = cbrt((sqrt((g * g) - (h * h)) - g) / (2.0 * a)) + (cbrt(-0.5 * (g + g)) / cbrt(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))))))) < -9.46556384914367152e-106 or -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 35.0
Simplified35.0
rmApplied div-inv_binary64_314435.0
Applied cbrt-prod_binary64_317833.6
Simplified33.6
Taylor expanded around -inf 48.5
Simplified32.3
if -9.46556384914367152e-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.4
Simplified60.4
rmApplied associate-*l/_binary64_309060.4
Applied cbrt-div_binary64_317940.7
Simplified40.7
Taylor expanded around inf 7.1
Final simplification31.4
herbie shell --seed 2021025
(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))))))))