\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[3]{2 \cdot a}\\
t_1 := \sqrt{g \cdot g - h \cdot h}\\
t_2 := g + t_1\\
t_3 := t_1 - g\\
t_4 := \sqrt[3]{\frac{1}{2 \cdot a} \cdot t_3} + \sqrt[3]{t_2 \cdot \frac{-1}{2 \cdot a}}\\
t_5 := \frac{\sqrt[3]{t_3}}{t_0}\\
t_6 := \sqrt[3]{\frac{t_2}{a} \cdot -0.5}\\
\mathbf{if}\;t_4 \leq -2.394584009627847 \cdot 10^{-97}:\\
\;\;\;\;t_5 + t_6\\
\mathbf{elif}\;t_4 \leq 2.0188474623397205 \cdot 10^{-106}:\\
\;\;\;\;t_6 + \frac{\sqrt[3]{g \cdot -2}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;t_5 + \frac{\sqrt[3]{t_2 \cdot -0.5}}{\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 (cbrt (* 2.0 a)))
(t_1 (sqrt (- (* g g) (* h h))))
(t_2 (+ g t_1))
(t_3 (- t_1 g))
(t_4
(+
(cbrt (* (/ 1.0 (* 2.0 a)) t_3))
(cbrt (* t_2 (/ -1.0 (* 2.0 a))))))
(t_5 (/ (cbrt t_3) t_0))
(t_6 (cbrt (* (/ t_2 a) -0.5))))
(if (<= t_4 -2.394584009627847e-97)
(+ t_5 t_6)
(if (<= t_4 2.0188474623397205e-106)
(+ t_6 (/ (cbrt (* g -2.0)) t_0))
(+ t_5 (/ (cbrt (* t_2 -0.5)) (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 = cbrt((2.0 * a));
double t_1 = sqrt(((g * g) - (h * h)));
double t_2 = g + t_1;
double t_3 = t_1 - g;
double t_4 = cbrt(((1.0 / (2.0 * a)) * t_3)) + cbrt((t_2 * (-1.0 / (2.0 * a))));
double t_5 = cbrt(t_3) / t_0;
double t_6 = cbrt(((t_2 / a) * -0.5));
double tmp;
if (t_4 <= -2.394584009627847e-97) {
tmp = t_5 + t_6;
} else if (t_4 <= 2.0188474623397205e-106) {
tmp = t_6 + (cbrt((g * -2.0)) / t_0);
} else {
tmp = t_5 + (cbrt((t_2 * -0.5)) / 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))))))) < -2.3945840096278469e-97Initial program 10.3
Simplified10.3
Applied cbrt-div_binary648.4
if -2.3945840096278469e-97 < (+.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))))))) < 2.01884746233972053e-106Initial program 53.6
Simplified53.6
Applied cbrt-div_binary6437.4
Taylor expanded in g around -inf 11.8
if 2.01884746233972053e-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))))))) Initial program 44.2
Simplified44.2
Applied cbrt-div_binary6443.3
Applied associate-*l/_binary6443.3
Applied cbrt-div_binary6442.4
Simplified42.4
Applied *-un-lft-identity_binary6442.4
Final simplification32.7
herbie shell --seed 2022160
(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))))))))