\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 := \sqrt{g \cdot g - h \cdot h}\\
\mathbf{if}\;g \leq 5.72792437368683 \cdot 10^{-152}:\\
\;\;\;\;\begin{array}{l}
t_1 := \sqrt[3]{g} \cdot \sqrt[3]{g}\\
t_2 := \sqrt[3]{g} \cdot t_1\\
t_3 := \sqrt[3]{t_0}\\
\sqrt[3]{\mathsf{fma}\left(t_3 \cdot t_3, t_3, -t_2\right) + \mathsf{fma}\left(-\sqrt[3]{g}, t_1, t_2\right)} \cdot \sqrt[3]{\frac{0.5}{a}} + \sqrt[3]{\frac{g + t_0}{a} \cdot -0.5}
\end{array}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{\frac{t_0 - g}{a \cdot 2}} + \frac{\sqrt[3]{-0.5 \cdot \left(g + \sqrt{g + h} \cdot \sqrt{g - 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
(let* ((t_0 (sqrt (- (* g g) (* h h)))))
(if (<= g 5.72792437368683e-152)
(let* ((t_1 (* (cbrt g) (cbrt g)))
(t_2 (* (cbrt g) t_1))
(t_3 (cbrt t_0)))
(+
(*
(cbrt (+ (fma (* t_3 t_3) t_3 (- t_2)) (fma (- (cbrt g)) t_1 t_2)))
(cbrt (/ 0.5 a)))
(cbrt (* (/ (+ g t_0) a) -0.5))))
(+
(cbrt (/ (- t_0 g) (* a 2.0)))
(/ (cbrt (* -0.5 (+ g (* (sqrt (+ g h)) (sqrt (- g 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 t_0 = sqrt((g * g) - (h * h));
double tmp;
if (g <= 5.72792437368683e-152) {
double t_1_1 = cbrt(g) * cbrt(g);
double t_2_2 = cbrt(g) * t_1_1;
double t_3_3 = cbrt(t_0);
tmp = (cbrt(fma((t_3_3 * t_3_3), t_3_3, -t_2_2) + fma(-cbrt(g), t_1_1, t_2_2)) * cbrt(0.5 / a)) + cbrt(((g + t_0) / a) * -0.5);
} else {
tmp = cbrt((t_0 - g) / (a * 2.0)) + (cbrt(-0.5 * (g + (sqrt(g + h) * sqrt(g - h)))) / cbrt(a));
}
return tmp;
}



Bits error versus g



Bits error versus h



Bits error versus a
if g < 5.72792437368683024e-152Initial program 37.0
Simplified37.0
Applied div-inv_binary6437.0
Applied cbrt-prod_binary6433.5
Simplified33.5
Applied add-cube-cbrt_binary6433.6
Applied add-cube-cbrt_binary6433.5
Applied prod-diff_binary6433.5
if 5.72792437368683024e-152 < g Initial program 35.0
Simplified35.0
Applied associate-*l/_binary6435.0
Applied cbrt-div_binary6431.1
Applied difference-of-squares_binary6431.1
Applied sqrt-prod_binary6431.1
Simplified31.1
Final simplification32.4
herbie shell --seed 2021275
(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))))))))