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



Bits error versus g



Bits error versus h



Bits error versus a
Results
if g < -2.4478446558884951e-171Initial program 34.5
rmApplied cbrt-prod_binary6431.0
Simplified31.0
Simplified31.0
Taylor expanded around -inf 37.2
Simplified31.1
if -2.4478446558884951e-171 < g Initial program 36.6
rmApplied cbrt-prod_binary6433.1
Simplified33.1
Taylor expanded around inf 31.9
Final simplification31.5
herbie shell --seed 2021148
(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))))))))