\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.854914823509544 \cdot 10^{-163}:\\
\;\;\;\;\frac{\sqrt[3]{g \cdot -2}}{t_1} + \sqrt[3]{\frac{t_0}{a} \cdot -0.5}\\
\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_2 := \sqrt{t_0}\\
\frac{\sqrt[3]{-0.5 \cdot \frac{h \cdot h}{g}}}{t_1} + \frac{\sqrt[3]{-0.5 \cdot \left(t_2 \cdot t_2\right)}}{\sqrt[3]{a}}
\end{array}\\
\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.854914823509544e-163)
(+ (/ (cbrt (* g -2.0)) t_1) (cbrt (* (/ t_0 a) -0.5)))
(let* ((t_2 (sqrt t_0)))
(+
(/ (cbrt (* -0.5 (/ (* h h) g))) t_1)
(/ (cbrt (* -0.5 (* t_2 t_2))) (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.854914823509544e-163) {
tmp = (cbrt(g * -2.0) / t_1) + cbrt((t_0 / a) * -0.5);
} else {
double t_2 = sqrt(t_0);
tmp = (cbrt(-0.5 * ((h * h) / g)) / t_1) + (cbrt(-0.5 * (t_2 * t_2)) / cbrt(a));
}
return tmp;
}



Bits error versus g



Bits error versus h



Bits error versus a
Results
if g < 1.854914823509544e-163Initial program 37.1
Simplified37.1
Applied cbrt-div_binary6433.2
Taylor expanded in g around -inf 32.1
if 1.854914823509544e-163 < g Initial program 35.3
Simplified35.3
Applied cbrt-div_binary6435.2
Applied associate-*l/_binary6435.2
Applied cbrt-div_binary6431.2
Simplified31.2
Applied add-sqr-sqrt_binary6431.2
Taylor expanded in g around inf 30.7
Simplified30.7
Final simplification31.4
herbie shell --seed 2022104
(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))))))))