\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}
t_0 := \sqrt{g \cdot g - h \cdot h}\\
t_1 := g + t_0\\
t_2 := t_0 - g\\
\mathbf{if}\;\begin{array}{l}
t_3 := \sqrt[3]{\frac{1}{2 \cdot a} \cdot t_2} + \sqrt[3]{t_1 \cdot \frac{-1}{2 \cdot a}}\\
t_3 \leq -8.639119737926423 \cdot 10^{-107} \lor \neg \left(t_3 \leq 0\right)
\end{array}:\\
\;\;\;\;\sqrt[3]{0.5} \cdot \left(\sqrt[3]{t_2} \cdot \sqrt[3]{\frac{1}{a}}\right) + \frac{\sqrt[3]{t_1 \cdot -0.5}}{\sqrt[3]{a}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{\frac{t_2}{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
(let* ((t_0 (sqrt (- (* g g) (* h h)))) (t_1 (+ g t_0)) (t_2 (- t_0 g)))
(if (let* ((t_3
(+
(cbrt (* (/ 1.0 (* 2.0 a)) t_2))
(cbrt (* t_1 (/ -1.0 (* 2.0 a)))))))
(or (<= t_3 -8.639119737926423e-107) (not (<= t_3 0.0))))
(+
(* (cbrt 0.5) (* (cbrt t_2) (cbrt (/ 1.0 a))))
(/ (cbrt (* t_1 -0.5)) (cbrt a)))
(+ (cbrt (/ t_2 (* 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 t_0 = sqrt((g * g) - (h * h));
double t_1 = g + t_0;
double t_2 = t_0 - g;
double t_3 = cbrt((1.0 / (2.0 * a)) * t_2) + cbrt(t_1 * (-1.0 / (2.0 * a)));
double tmp;
if ((t_3 <= -8.639119737926423e-107) || !(t_3 <= 0.0)) {
tmp = (cbrt(0.5) * (cbrt(t_2) * cbrt(1.0 / a))) + (cbrt(t_1 * -0.5) / cbrt(a));
} else {
tmp = cbrt(t_2 / (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))))))) < -8.6391197379264234e-107 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.5
Simplified35.5
Applied associate-*l/_binary6435.5
Applied cbrt-div_binary6434.3
Applied add-cube-cbrt_binary6441.2
Applied add-cube-cbrt_binary6434.4
Applied prod-diff_binary6434.4
Applied *-un-lft-identity_binary6434.4
Applied times-frac_binary6434.4
Applied cbrt-prod_binary6434.4
Applied div-inv_binary6434.4
Applied cbrt-prod_binary6433.2
Simplified33.1
if -8.6391197379264234e-107 < (+.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.7
Simplified60.3
Applied associate-*l/_binary6460.3
Applied cbrt-div_binary6440.5
Taylor expanded in g around inf 7.8
Final simplification32.2
herbie shell --seed 2022005
(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))))))))