(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 (* h (- h)))
(t_1 (sqrt (- (* g g) (* h h))))
(t_2
(+
(cbrt (* (/ 0.5 a) (- t_1 g)))
(/ (cbrt (* (+ g (sqrt (fma g g t_0))) -0.5)) (cbrt a)))))
(if (<= h -4.3708065047631245e-179)
t_2
(if (<= h 6.613043387155913e-258)
(+
(/ (cbrt (* 0.5 (- (hypot g (sqrt t_0)) g))) (cbrt a))
(cbrt (* (+ g t_1) (/ -0.5 a))))
t_2))))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 = h * -h;
double t_1 = sqrt(((g * g) - (h * h)));
double t_2 = cbrt(((0.5 / a) * (t_1 - g))) + (cbrt(((g + sqrt(fma(g, g, t_0))) * -0.5)) / cbrt(a));
double tmp;
if (h <= -4.3708065047631245e-179) {
tmp = t_2;
} else if (h <= 6.613043387155913e-258) {
tmp = (cbrt((0.5 * (hypot(g, sqrt(t_0)) - g))) / cbrt(a)) + cbrt(((g + t_1) * (-0.5 / a)));
} else {
tmp = t_2;
}
return tmp;
}
function code(g, h, a) return Float64(cbrt(Float64(Float64(1.0 / Float64(2.0 * a)) * Float64(Float64(-g) + sqrt(Float64(Float64(g * g) - Float64(h * h)))))) + cbrt(Float64(Float64(1.0 / Float64(2.0 * a)) * Float64(Float64(-g) - sqrt(Float64(Float64(g * g) - Float64(h * h))))))) end
function code(g, h, a) t_0 = Float64(h * Float64(-h)) t_1 = sqrt(Float64(Float64(g * g) - Float64(h * h))) t_2 = Float64(cbrt(Float64(Float64(0.5 / a) * Float64(t_1 - g))) + Float64(cbrt(Float64(Float64(g + sqrt(fma(g, g, t_0))) * -0.5)) / cbrt(a))) tmp = 0.0 if (h <= -4.3708065047631245e-179) tmp = t_2; elseif (h <= 6.613043387155913e-258) tmp = Float64(Float64(cbrt(Float64(0.5 * Float64(hypot(g, sqrt(t_0)) - g))) / cbrt(a)) + cbrt(Float64(Float64(g + t_1) * Float64(-0.5 / a)))); else tmp = t_2; end return tmp end
code[g_, h_, a_] := N[(N[Power[N[(N[(1.0 / N[(2.0 * a), $MachinePrecision]), $MachinePrecision] * N[((-g) + N[Sqrt[N[(N[(g * g), $MachinePrecision] - N[(h * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(N[(1.0 / N[(2.0 * a), $MachinePrecision]), $MachinePrecision] * N[((-g) - N[Sqrt[N[(N[(g * g), $MachinePrecision] - N[(h * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
code[g_, h_, a_] := Block[{t$95$0 = N[(h * (-h)), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[(g * g), $MachinePrecision] - N[(h * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(t$95$1 - g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[(N[Power[N[(N[(g + N[Sqrt[N[(g * g + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[h, -4.3708065047631245e-179], t$95$2, If[LessEqual[h, 6.613043387155913e-258], N[(N[(N[Power[N[(0.5 * N[(N[Sqrt[g ^ 2 + N[Sqrt[t$95$0], $MachinePrecision] ^ 2], $MachinePrecision] - g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[(g + t$95$1), $MachinePrecision] * N[(-0.5 / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], t$95$2]]]]]
\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 := h \cdot \left(-h\right)\\
t_1 := \sqrt{g \cdot g - h \cdot h}\\
t_2 := \sqrt[3]{\frac{0.5}{a} \cdot \left(t_1 - g\right)} + \frac{\sqrt[3]{\left(g + \sqrt{\mathsf{fma}\left(g, g, t_0\right)}\right) \cdot -0.5}}{\sqrt[3]{a}}\\
\mathbf{if}\;h \leq -4.3708065047631245 \cdot 10^{-179}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;h \leq 6.613043387155913 \cdot 10^{-258}:\\
\;\;\;\;\frac{\sqrt[3]{0.5 \cdot \left(\mathsf{hypot}\left(g, \sqrt{t_0}\right) - g\right)}}{\sqrt[3]{a}} + \sqrt[3]{\left(g + t_1\right) \cdot \frac{-0.5}{a}}\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
if h < -4.37080650476312451e-179 or 6.6130433871559132e-258 < h Initial program 37.8
Simplified37.8
Applied egg-rr42.8
Applied egg-rr41.1
Applied egg-rr35.9
if -4.37080650476312451e-179 < h < 6.6130433871559132e-258Initial program 31.3
Simplified31.3
Applied egg-rr28.0
Final simplification33.8
herbie shell --seed 2022210
(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))))))))