\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\\
t_3 := \sqrt[3]{\frac{1}{2 \cdot a} \cdot t_2} + \sqrt[3]{t_1 \cdot \frac{-1}{2 \cdot a}}\\
t_4 := \sqrt[3]{t_2}\\
\mathbf{if}\;t_3 \leq -1.9430711755519203 \cdot 10^{-100}:\\
\;\;\;\;\frac{t_4}{\sqrt[3]{2 \cdot a}} + \frac{\sqrt[3]{t_1 \cdot -0.5}}{\sqrt[3]{a}}\\
\mathbf{elif}\;t_3 \leq 0:\\
\;\;\;\;\sqrt[3]{\frac{t_2}{2 \cdot a}} + \frac{\sqrt[3]{-0.5 \cdot \left(g + g\right)}}{\sqrt[3]{a}}\\
\mathbf{else}:\\
\;\;\;\;t_4 \cdot \sqrt[3]{\frac{0.5}{a}} + \sqrt[3]{-0.5 \cdot \frac{g + \left|t_0\right|}{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))
(t_3
(+
(cbrt (* (/ 1.0 (* 2.0 a)) t_2))
(cbrt (* t_1 (/ -1.0 (* 2.0 a))))))
(t_4 (cbrt t_2)))
(if (<= t_3 -1.9430711755519203e-100)
(+ (/ t_4 (cbrt (* 2.0 a))) (/ (cbrt (* t_1 -0.5)) (cbrt a)))
(if (<= t_3 0.0)
(+ (cbrt (/ t_2 (* 2.0 a))) (/ (cbrt (* -0.5 (+ g g))) (cbrt a)))
(+ (* t_4 (cbrt (/ 0.5 a))) (cbrt (* -0.5 (/ (+ g (fabs t_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 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 t_4 = cbrt(t_2);
double tmp;
if (t_3 <= -1.9430711755519203e-100) {
tmp = (t_4 / cbrt(2.0 * a)) + (cbrt(t_1 * -0.5) / cbrt(a));
} else if (t_3 <= 0.0) {
tmp = cbrt(t_2 / (2.0 * a)) + (cbrt(-0.5 * (g + g)) / cbrt(a));
} else {
tmp = (t_4 * cbrt(0.5 / a)) + cbrt(-0.5 * ((g + fabs(t_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))))))) < -1.94307117555192034e-100Initial program 10.6
Simplified10.5
Applied associate-*l/_binary6410.5
Applied cbrt-div_binary648.5
Applied cbrt-div_binary646.2
if -1.94307117555192034e-100 < (+.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 57.4
Simplified57.3
Applied associate-*l/_binary6457.3
Applied cbrt-div_binary6440.2
Taylor expanded in g around inf 9.1
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.2
Simplified44.2
Applied div-inv_binary6444.2
Applied cbrt-prod_binary6443.2
Simplified43.2
Applied add-sqr-sqrt_binary6443.2
Applied rem-sqrt-square_binary6443.2
Final simplification32.4
herbie shell --seed 2021215
(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))))))))