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



Bits error versus g



Bits error versus h



Bits error versus a
Results
if g < 3.12385343604672747e-176Initial program 36.4
Simplified36.4
rmApplied cbrt-div_binary64_352032.5
Taylor expanded around -inf 31.5
if 3.12385343604672747e-176 < g Initial program 34.5
Simplified34.5
rmApplied associate-*l/_binary64_343134.5
Applied cbrt-div_binary64_352030.1
Simplified30.1
Taylor expanded around inf 30.3
Final simplification30.9
herbie shell --seed 2021022
(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))))))))