\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]{a \cdot 2}\\
t_1 := \sqrt{g \cdot g - h \cdot h}\\
t_2 := t_1 - g\\
t_3 := \sqrt[3]{\frac{0.5}{a}} \cdot \sqrt[3]{t_2}\\
\mathbf{if}\;g \leq -1.2893397083911 \cdot 10^{-188}:\\
\;\;\;\;t_3 + \frac{\sqrt[3]{\frac{h \cdot h}{g} \cdot -0.5}}{t_0}\\
\mathbf{elif}\;g \leq 4.467477958425206 \cdot 10^{-133}:\\
\;\;\;\;\sqrt[3]{t_2 \cdot \frac{1}{a \cdot 2}} + \frac{\sqrt[3]{g \cdot -2}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_4 := \sqrt{t_1}\\
t_3 + \frac{\sqrt[3]{\left(-g\right) - t_4 \cdot t_4}}{t_0}
\end{array}\\
\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 (* a 2.0)))
(t_1 (sqrt (- (* g g) (* h h))))
(t_2 (- t_1 g))
(t_3 (* (cbrt (/ 0.5 a)) (cbrt t_2))))
(if (<= g -1.2893397083911e-188)
(+ t_3 (/ (cbrt (* (/ (* h h) g) -0.5)) t_0))
(if (<= g 4.467477958425206e-133)
(+ (cbrt (* t_2 (/ 1.0 (* a 2.0)))) (/ (cbrt (* g -2.0)) t_0))
(let* ((t_4 (sqrt t_1)))
(+ t_3 (/ (cbrt (- (- g) (* t_4 t_4))) t_0)))))))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(a * 2.0);
double t_1 = sqrt((g * g) - (h * h));
double t_2 = t_1 - g;
double t_3 = cbrt(0.5 / a) * cbrt(t_2);
double tmp;
if (g <= -1.2893397083911e-188) {
tmp = t_3 + (cbrt(((h * h) / g) * -0.5) / t_0);
} else if (g <= 4.467477958425206e-133) {
tmp = cbrt(t_2 * (1.0 / (a * 2.0))) + (cbrt(g * -2.0) / t_0);
} else {
double t_4 = sqrt(t_1);
tmp = t_3 + (cbrt(-g - (t_4 * t_4)) / t_0);
}
return tmp;
}



Bits error versus g



Bits error versus h



Bits error versus a
Results
if g < -1.2893397083910999e-188Initial program 35.2
Applied associate-*l/_binary6435.2
Applied cbrt-div_binary6435.2
Simplified35.2
Applied cbrt-prod_binary6431.3
Simplified31.3
Simplified31.3
Taylor expanded in g around -inf 30.7
Simplified30.7
if -1.2893397083910999e-188 < g < 4.46747795842520638e-133Initial program 49.4
Applied associate-*l/_binary6449.4
Applied cbrt-div_binary6444.1
Simplified44.1
Taylor expanded in g around inf 33.4
if 4.46747795842520638e-133 < g Initial program 35.1
Applied associate-*l/_binary6435.1
Applied cbrt-div_binary6431.9
Simplified31.9
Applied cbrt-prod_binary6431.8
Simplified31.8
Simplified31.8
Applied add-sqr-sqrt_binary6431.8
Final simplification31.4
herbie shell --seed 2022097
(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))))))))