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



Bits error versus g



Bits error versus h



Bits error versus a
Results
if g < 1.4433633331664534e-159Initial program 37.2
Simplified37.2
Applied cbrt-div_binary6433.8
Taylor expanded in g around -inf 32.7
if 1.4433633331664534e-159 < g Initial program 35.1
Simplified35.1
Applied cbrt-div_binary6435.1
Applied associate-*l/_binary6435.1
Applied cbrt-div_binary6431.7
Simplified31.7
Taylor expanded in g around inf 30.1
Simplified30.1
Final simplification31.5
herbie shell --seed 2022068
(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))))))))