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



Bits error versus g



Bits error versus h



Bits error versus a
Results
if g < 4.2462450105756327e-182Initial program 37.3
Simplified37.3
Applied cbrt-div_binary6433.7
Taylor expanded in g around -inf 32.7
if 4.2462450105756327e-182 < g Initial program 35.0
Simplified35.0
Applied cbrt-div_binary6434.9
Taylor expanded in g around inf 33.5
Final simplification33.1
herbie shell --seed 2022088
(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))))))))