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



Bits error versus g



Bits error versus h



Bits error versus a
Results
if g < -1.78826234397178945e-170Initial program 34.9
rmApplied cbrt-prod_binary64_249630.9
Simplified30.8
Simplified30.8
rmApplied flip--_binary64_244030.7
Applied frac-times_binary64_247531.8
Applied cbrt-div_binary64_249731.7
Simplified31.2
Simplified31.2
if -1.78826234397178945e-170 < g Initial program 36.7
rmApplied associate-*l/_binary64_240836.7
Applied cbrt-div_binary64_249733.0
Simplified33.0
Taylor expanded around inf 31.9
Final simplification31.5
herbie shell --seed 2021059
(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))))))))