\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[3]{2 \cdot a}\\
t_1 := \sqrt{g \cdot g - h \cdot h}\\
t_2 := \frac{\sqrt[3]{\left(-g\right) - t_1}}{t_0}\\
t_3 := t_1 - g\\
t_4 := \sqrt[3]{\frac{1}{2 \cdot a} \cdot t_3} + \sqrt[3]{\left(g + t_1\right) \cdot \frac{-1}{2 \cdot a}}\\
t_5 := \sqrt[3]{t_3}\\
\mathbf{if}\;t_4 \leq -2.6688122044117306 \cdot 10^{-103}:\\
\;\;\;\;\frac{t_5}{t_0} + t_2\\
\mathbf{elif}\;t_4 \leq 0:\\
\;\;\;\;\sqrt[3]{\frac{t_3}{a}} \cdot \sqrt[3]{0.5} + \frac{\sqrt[3]{\left(-g\right) - g}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;t_2 + \sqrt[3]{0.5} \cdot \frac{t_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 (cbrt (* 2.0 a)))
(t_1 (sqrt (- (* g g) (* h h))))
(t_2 (/ (cbrt (- (- g) t_1)) t_0))
(t_3 (- t_1 g))
(t_4
(+
(cbrt (* (/ 1.0 (* 2.0 a)) t_3))
(cbrt (* (+ g t_1) (/ -1.0 (* 2.0 a))))))
(t_5 (cbrt t_3)))
(if (<= t_4 -2.6688122044117306e-103)
(+ (/ t_5 t_0) t_2)
(if (<= t_4 0.0)
(+ (* (cbrt (/ t_3 a)) (cbrt 0.5)) (/ (cbrt (- (- g) g)) t_0))
(+ t_2 (* (cbrt 0.5) (/ t_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 = cbrt(2.0 * a);
double t_1 = sqrt((g * g) - (h * h));
double t_2 = cbrt(-g - t_1) / t_0;
double t_3 = t_1 - g;
double t_4 = cbrt((1.0 / (2.0 * a)) * t_3) + cbrt((g + t_1) * (-1.0 / (2.0 * a)));
double t_5 = cbrt(t_3);
double tmp;
if (t_4 <= -2.6688122044117306e-103) {
tmp = (t_5 / t_0) + t_2;
} else if (t_4 <= 0.0) {
tmp = (cbrt(t_3 / a) * cbrt(0.5)) + (cbrt(-g - g) / t_0);
} else {
tmp = t_2 + (cbrt(0.5) * (t_5 / cbrt(a)));
}
return tmp;
}



Bits error versus g



Bits error versus h



Bits error versus a
Results
if (+.f64 (cbrt.f64 (*.f64 (/.f64 1 (*.f64 2 a)) (+.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h)))))) (cbrt.f64 (*.f64 (/.f64 1 (*.f64 2 a)) (-.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h))))))) < -2.6688122044117306e-103Initial program 10.2
rmApplied associate-*l/_binary6410.2
Applied cbrt-div_binary647.9
Simplified7.9
rmApplied associate-*l/_binary647.9
Applied cbrt-div_binary645.7
Simplified5.7
if -2.6688122044117306e-103 < (+.f64 (cbrt.f64 (*.f64 (/.f64 1 (*.f64 2 a)) (+.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h)))))) (cbrt.f64 (*.f64 (/.f64 1 (*.f64 2 a)) (-.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h))))))) < -0.0Initial program 58.1
rmApplied associate-*l/_binary6458.1
Applied cbrt-div_binary6437.6
Simplified37.6
Taylor expanded around 0 44.7
Simplified37.5
Taylor expanded around inf 9.1
if -0.0 < (+.f64 (cbrt.f64 (*.f64 (/.f64 1 (*.f64 2 a)) (+.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h)))))) (cbrt.f64 (*.f64 (/.f64 1 (*.f64 2 a)) (-.f64 (neg.f64 g) (sqrt.f64 (-.f64 (*.f64 g g) (*.f64 h h))))))) Initial program 44.3
rmApplied associate-*l/_binary6444.3
Applied cbrt-div_binary6443.3
Simplified43.3
Taylor expanded around 0 53.9
Simplified43.3
rmApplied cbrt-div_binary6442.3
Final simplification31.6
herbie shell --seed 2021198
(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))))))))