\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 := g + \sqrt{g \cdot g - h \cdot h}\\
t_1 := \sqrt[3]{2 \cdot a}\\
\mathbf{if}\;g \leq 1.302569325886384 \cdot 10^{-171}:\\
\;\;\;\;\frac{\sqrt[3]{\left(-g\right) - g}}{t_1} + \sqrt[3]{\frac{t_0}{a} \cdot -0.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt[3]{-0.5 \cdot \frac{{h}^{2}}{g}}}{t_1} + \frac{\sqrt[3]{t_0 \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 (+ g (sqrt (- (* g g) (* h h))))) (t_1 (cbrt (* 2.0 a))))
(if (<= g 1.302569325886384e-171)
(+ (/ (cbrt (- (- g) g)) t_1) (cbrt (* (/ t_0 a) -0.5)))
(+
(/ (cbrt (* -0.5 (/ (pow h 2.0) g))) t_1)
(/ (cbrt (* t_0 -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 = g + sqrt((g * g) - (h * h));
double t_1 = cbrt(2.0 * a);
double tmp;
if (g <= 1.302569325886384e-171) {
tmp = (cbrt(-g - g) / t_1) + cbrt((t_0 / a) * -0.5);
} else {
tmp = (cbrt(-0.5 * (pow(h, 2.0) / g)) / t_1) + (cbrt(t_0 * -0.5) / cbrt(a));
}
return tmp;
}



Bits error versus g



Bits error versus h



Bits error versus a
Results
if g < 1.302569325886384e-171Initial program 36.5
Simplified36.5
Applied cbrt-div_binary6433.2
Taylor expanded in g around -inf 32.2
Simplified32.2
if 1.302569325886384e-171 < g Initial program 35.1
Simplified35.1
Applied cbrt-div_binary6435.0
Applied associate-*l/_binary6435.0
Applied cbrt-div_binary6431.4
Simplified31.4
Taylor expanded in g around inf 30.9
Final simplification31.6
herbie shell --seed 2022081
(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))))))))