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



Bits error versus g



Bits error versus h



Bits error versus a
Results
if g < 2.27194174318088427e-159Initial program 37.1
Simplified37.1
rmApplied cbrt-div_binary64_283833.0
rmApplied difference-of-squares_binary64_277533.0
Taylor expanded around -inf 31.8
Simplified31.8
if 2.27194174318088427e-159 < g Initial program 34.9
Simplified34.9
rmApplied associate-*l/_binary64_274934.9
Applied cbrt-div_binary64_283831.1
Final simplification31.5
herbie shell --seed 2020346
(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))))))))