
(FPCore (g h a) :precision binary64 (let* ((t_0 (/ 1.0 (* 2.0 a))) (t_1 (sqrt (- (* g g) (* h h))))) (+ (cbrt (* t_0 (+ (- g) t_1))) (cbrt (* t_0 (- (- g) t_1))))))
double code(double g, double h, double a) {
double t_0 = 1.0 / (2.0 * a);
double t_1 = sqrt(((g * g) - (h * h)));
return cbrt((t_0 * (-g + t_1))) + cbrt((t_0 * (-g - t_1)));
}
public static double code(double g, double h, double a) {
double t_0 = 1.0 / (2.0 * a);
double t_1 = Math.sqrt(((g * g) - (h * h)));
return Math.cbrt((t_0 * (-g + t_1))) + Math.cbrt((t_0 * (-g - t_1)));
}
function code(g, h, a) t_0 = Float64(1.0 / Float64(2.0 * a)) t_1 = sqrt(Float64(Float64(g * g) - Float64(h * h))) return Float64(cbrt(Float64(t_0 * Float64(Float64(-g) + t_1))) + cbrt(Float64(t_0 * Float64(Float64(-g) - t_1)))) end
code[g_, h_, a_] := Block[{t$95$0 = N[(1.0 / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[(g * g), $MachinePrecision] - N[(h * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[(N[Power[N[(t$95$0 * N[((-g) + t$95$1), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(t$95$0 * N[((-g) - t$95$1), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{2 \cdot a}\\
t_1 := \sqrt{g \cdot g - h \cdot h}\\
\sqrt[3]{t_0 \cdot \left(\left(-g\right) + t_1\right)} + \sqrt[3]{t_0 \cdot \left(\left(-g\right) - t_1\right)}
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 6 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (g h a) :precision binary64 (let* ((t_0 (/ 1.0 (* 2.0 a))) (t_1 (sqrt (- (* g g) (* h h))))) (+ (cbrt (* t_0 (+ (- g) t_1))) (cbrt (* t_0 (- (- g) t_1))))))
double code(double g, double h, double a) {
double t_0 = 1.0 / (2.0 * a);
double t_1 = sqrt(((g * g) - (h * h)));
return cbrt((t_0 * (-g + t_1))) + cbrt((t_0 * (-g - t_1)));
}
public static double code(double g, double h, double a) {
double t_0 = 1.0 / (2.0 * a);
double t_1 = Math.sqrt(((g * g) - (h * h)));
return Math.cbrt((t_0 * (-g + t_1))) + Math.cbrt((t_0 * (-g - t_1)));
}
function code(g, h, a) t_0 = Float64(1.0 / Float64(2.0 * a)) t_1 = sqrt(Float64(Float64(g * g) - Float64(h * h))) return Float64(cbrt(Float64(t_0 * Float64(Float64(-g) + t_1))) + cbrt(Float64(t_0 * Float64(Float64(-g) - t_1)))) end
code[g_, h_, a_] := Block[{t$95$0 = N[(1.0 / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[(g * g), $MachinePrecision] - N[(h * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[(N[Power[N[(t$95$0 * N[((-g) + t$95$1), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(t$95$0 * N[((-g) - t$95$1), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{2 \cdot a}\\
t_1 := \sqrt{g \cdot g - h \cdot h}\\
\sqrt[3]{t_0 \cdot \left(\left(-g\right) + t_1\right)} + \sqrt[3]{t_0 \cdot \left(\left(-g\right) - t_1\right)}
\end{array}
\end{array}
(FPCore (g h a)
:precision binary64
(let* ((t_0 (sqrt (* (+ h g) (- g h)))))
(if (<= (* h h) 0.0)
(+
(cbrt (* (- g t_0) (/ -0.5 a)))
(* (cbrt (/ -0.5 a)) (cbrt (+ g (hypot g (sqrt (* h (- h))))))))
(+
(cbrt (* (/ -0.5 a) (- g (sqrt (- (* g g) (* h h))))))
(cbrt (* (/ -0.5 a) (+ g t_0)))))))
double code(double g, double h, double a) {
double t_0 = sqrt(((h + g) * (g - h)));
double tmp;
if ((h * h) <= 0.0) {
tmp = cbrt(((g - t_0) * (-0.5 / a))) + (cbrt((-0.5 / a)) * cbrt((g + hypot(g, sqrt((h * -h))))));
} else {
tmp = cbrt(((-0.5 / a) * (g - sqrt(((g * g) - (h * h)))))) + cbrt(((-0.5 / a) * (g + t_0)));
}
return tmp;
}
public static double code(double g, double h, double a) {
double t_0 = Math.sqrt(((h + g) * (g - h)));
double tmp;
if ((h * h) <= 0.0) {
tmp = Math.cbrt(((g - t_0) * (-0.5 / a))) + (Math.cbrt((-0.5 / a)) * Math.cbrt((g + Math.hypot(g, Math.sqrt((h * -h))))));
} else {
tmp = Math.cbrt(((-0.5 / a) * (g - Math.sqrt(((g * g) - (h * h)))))) + Math.cbrt(((-0.5 / a) * (g + t_0)));
}
return tmp;
}
function code(g, h, a) t_0 = sqrt(Float64(Float64(h + g) * Float64(g - h))) tmp = 0.0 if (Float64(h * h) <= 0.0) tmp = Float64(cbrt(Float64(Float64(g - t_0) * Float64(-0.5 / a))) + Float64(cbrt(Float64(-0.5 / a)) * cbrt(Float64(g + hypot(g, sqrt(Float64(h * Float64(-h)))))))); else tmp = Float64(cbrt(Float64(Float64(-0.5 / a) * Float64(g - sqrt(Float64(Float64(g * g) - Float64(h * h)))))) + cbrt(Float64(Float64(-0.5 / a) * Float64(g + t_0)))); end return tmp end
code[g_, h_, a_] := Block[{t$95$0 = N[Sqrt[N[(N[(h + g), $MachinePrecision] * N[(g - h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(h * h), $MachinePrecision], 0.0], N[(N[Power[N[(N[(g - t$95$0), $MachinePrecision] * N[(-0.5 / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[(N[Power[N[(-0.5 / a), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[N[(g + N[Sqrt[g ^ 2 + N[Sqrt[N[(h * (-h)), $MachinePrecision]], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(N[(-0.5 / a), $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[(-0.5 / a), $MachinePrecision] * N[(g + t$95$0), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\left(h + g\right) \cdot \left(g - h\right)}\\
\mathbf{if}\;h \cdot h \leq 0:\\
\;\;\;\;\sqrt[3]{\left(g - t_0\right) \cdot \frac{-0.5}{a}} + \sqrt[3]{\frac{-0.5}{a}} \cdot \sqrt[3]{g + \mathsf{hypot}\left(g, \sqrt{h \cdot \left(-h\right)}\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{\frac{-0.5}{a} \cdot \left(g - \sqrt{g \cdot g - h \cdot h}\right)} + \sqrt[3]{\frac{-0.5}{a} \cdot \left(g + t_0\right)}\\
\end{array}
\end{array}
if (*.f64 h h) < 0.0Initial program 47.2%
Simplified47.2%
cbrt-prod53.7%
difference-of-squares53.7%
fma-neg53.7%
fma-neg53.7%
difference-of-squares53.7%
difference-of-squares53.7%
sub-neg53.7%
add-sqr-sqrt53.7%
hypot-def58.0%
distribute-rgt-neg-in58.0%
Applied egg-rr58.0%
*-commutative58.0%
Simplified58.0%
if 0.0 < (*.f64 h h) Initial program 36.1%
Simplified36.1%
pow1/236.1%
difference-of-squares36.1%
Applied egg-rr36.1%
unpow1/236.1%
Simplified36.1%
Final simplification45.9%
(FPCore (g h a)
:precision binary64
(if (<= g 1e-180)
(+
(cbrt (* (/ 0.5 a) (- (sqrt (- (* g g) (* h h))) g)))
(cbrt (* (/ 0.5 a) (* -0.5 (/ (* h h) g)))))
(+
(cbrt (* (/ -0.5 a) (+ g (sqrt (* (+ h g) (- g h))))))
(cbrt (* (/ -0.5 a) (- g g))))))
double code(double g, double h, double a) {
double tmp;
if (g <= 1e-180) {
tmp = cbrt(((0.5 / a) * (sqrt(((g * g) - (h * h))) - g))) + cbrt(((0.5 / a) * (-0.5 * ((h * h) / g))));
} else {
tmp = cbrt(((-0.5 / a) * (g + sqrt(((h + g) * (g - h)))))) + cbrt(((-0.5 / a) * (g - g)));
}
return tmp;
}
public static double code(double g, double h, double a) {
double tmp;
if (g <= 1e-180) {
tmp = Math.cbrt(((0.5 / a) * (Math.sqrt(((g * g) - (h * h))) - g))) + Math.cbrt(((0.5 / a) * (-0.5 * ((h * h) / g))));
} else {
tmp = Math.cbrt(((-0.5 / a) * (g + Math.sqrt(((h + g) * (g - h)))))) + Math.cbrt(((-0.5 / a) * (g - g)));
}
return tmp;
}
function code(g, h, a) tmp = 0.0 if (g <= 1e-180) tmp = Float64(cbrt(Float64(Float64(0.5 / a) * Float64(sqrt(Float64(Float64(g * g) - Float64(h * h))) - g))) + cbrt(Float64(Float64(0.5 / a) * Float64(-0.5 * Float64(Float64(h * h) / g))))); else tmp = Float64(cbrt(Float64(Float64(-0.5 / a) * Float64(g + sqrt(Float64(Float64(h + g) * Float64(g - h)))))) + cbrt(Float64(Float64(-0.5 / a) * Float64(g - g)))); end return tmp end
code[g_, h_, a_] := If[LessEqual[g, 1e-180], N[(N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(N[Sqrt[N[(N[(g * g), $MachinePrecision] - N[(h * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(-0.5 * N[(N[(h * h), $MachinePrecision] / g), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(N[(-0.5 / a), $MachinePrecision] * N[(g + N[Sqrt[N[(N[(h + g), $MachinePrecision] * N[(g - h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(N[(-0.5 / a), $MachinePrecision] * N[(g - g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;g \leq 10^{-180}:\\
\;\;\;\;\sqrt[3]{\frac{0.5}{a} \cdot \left(\sqrt{g \cdot g - h \cdot h} - g\right)} + \sqrt[3]{\frac{0.5}{a} \cdot \left(-0.5 \cdot \frac{h \cdot h}{g}\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{\frac{-0.5}{a} \cdot \left(g + \sqrt{\left(h + g\right) \cdot \left(g - h\right)}\right)} + \sqrt[3]{\frac{-0.5}{a} \cdot \left(g - g\right)}\\
\end{array}
\end{array}
if g < 1e-180Initial program 38.7%
associate-/r*38.7%
metadata-eval38.7%
+-commutative38.7%
unsub-neg38.7%
associate-/r*38.7%
metadata-eval38.7%
Simplified38.7%
Taylor expanded in g around -inf 41.3%
unpow241.3%
Simplified41.3%
if 1e-180 < g Initial program 43.6%
Simplified43.6%
Taylor expanded in g around inf 44.5%
Final simplification42.8%
(FPCore (g h a)
:precision binary64
(if (<= g -1.6e-162)
(+
(cbrt (* (/ 0.5 a) (- (+ g g))))
(cbrt (* (/ 0.5 a) (- (- g) (sqrt (- (* g g) (* h h)))))))
(+
(cbrt (* (/ -0.5 a) (+ g (sqrt (* (+ h g) (- g h))))))
(cbrt (* (/ -0.5 a) (- g g))))))
double code(double g, double h, double a) {
double tmp;
if (g <= -1.6e-162) {
tmp = cbrt(((0.5 / a) * -(g + g))) + cbrt(((0.5 / a) * (-g - sqrt(((g * g) - (h * h))))));
} else {
tmp = cbrt(((-0.5 / a) * (g + sqrt(((h + g) * (g - h)))))) + cbrt(((-0.5 / a) * (g - g)));
}
return tmp;
}
public static double code(double g, double h, double a) {
double tmp;
if (g <= -1.6e-162) {
tmp = Math.cbrt(((0.5 / a) * -(g + g))) + Math.cbrt(((0.5 / a) * (-g - Math.sqrt(((g * g) - (h * h))))));
} else {
tmp = Math.cbrt(((-0.5 / a) * (g + Math.sqrt(((h + g) * (g - h)))))) + Math.cbrt(((-0.5 / a) * (g - g)));
}
return tmp;
}
function code(g, h, a) tmp = 0.0 if (g <= -1.6e-162) tmp = Float64(cbrt(Float64(Float64(0.5 / a) * Float64(-Float64(g + g)))) + cbrt(Float64(Float64(0.5 / a) * Float64(Float64(-g) - sqrt(Float64(Float64(g * g) - Float64(h * h))))))); else tmp = Float64(cbrt(Float64(Float64(-0.5 / a) * Float64(g + sqrt(Float64(Float64(h + g) * Float64(g - h)))))) + cbrt(Float64(Float64(-0.5 / a) * Float64(g - g)))); end return tmp end
code[g_, h_, a_] := If[LessEqual[g, -1.6e-162], N[(N[Power[N[(N[(0.5 / a), $MachinePrecision] * (-N[(g + g), $MachinePrecision])), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[((-g) - N[Sqrt[N[(N[(g * g), $MachinePrecision] - N[(h * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(N[(-0.5 / a), $MachinePrecision] * N[(g + N[Sqrt[N[(N[(h + g), $MachinePrecision] * N[(g - h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(N[(-0.5 / a), $MachinePrecision] * N[(g - g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;g \leq -1.6 \cdot 10^{-162}:\\
\;\;\;\;\sqrt[3]{\frac{0.5}{a} \cdot \left(-\left(g + g\right)\right)} + \sqrt[3]{\frac{0.5}{a} \cdot \left(\left(-g\right) - \sqrt{g \cdot g - h \cdot h}\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{\frac{-0.5}{a} \cdot \left(g + \sqrt{\left(h + g\right) \cdot \left(g - h\right)}\right)} + \sqrt[3]{\frac{-0.5}{a} \cdot \left(g - g\right)}\\
\end{array}
\end{array}
if g < -1.59999999999999988e-162Initial program 42.5%
associate-/r*42.5%
metadata-eval42.5%
+-commutative42.5%
unsub-neg42.5%
associate-/r*42.5%
metadata-eval42.5%
Simplified42.5%
Taylor expanded in g around -inf 42.1%
neg-mul-142.1%
Simplified42.1%
if -1.59999999999999988e-162 < g Initial program 39.9%
Simplified39.9%
Taylor expanded in g around inf 40.7%
Final simplification41.4%
(FPCore (g h a)
:precision binary64
(if (<= g 1e-180)
(+
(cbrt (* (/ 0.5 a) (- (sqrt (- (* g g) (* h h))) g)))
(cbrt (* (/ 0.5 a) (- g g))))
(+
(cbrt (* (/ -0.5 a) (+ g (sqrt (* (+ h g) (- g h))))))
(cbrt (* (/ -0.5 a) (- g g))))))
double code(double g, double h, double a) {
double tmp;
if (g <= 1e-180) {
tmp = cbrt(((0.5 / a) * (sqrt(((g * g) - (h * h))) - g))) + cbrt(((0.5 / a) * (g - g)));
} else {
tmp = cbrt(((-0.5 / a) * (g + sqrt(((h + g) * (g - h)))))) + cbrt(((-0.5 / a) * (g - g)));
}
return tmp;
}
public static double code(double g, double h, double a) {
double tmp;
if (g <= 1e-180) {
tmp = Math.cbrt(((0.5 / a) * (Math.sqrt(((g * g) - (h * h))) - g))) + Math.cbrt(((0.5 / a) * (g - g)));
} else {
tmp = Math.cbrt(((-0.5 / a) * (g + Math.sqrt(((h + g) * (g - h)))))) + Math.cbrt(((-0.5 / a) * (g - g)));
}
return tmp;
}
function code(g, h, a) tmp = 0.0 if (g <= 1e-180) tmp = Float64(cbrt(Float64(Float64(0.5 / a) * Float64(sqrt(Float64(Float64(g * g) - Float64(h * h))) - g))) + cbrt(Float64(Float64(0.5 / a) * Float64(g - g)))); else tmp = Float64(cbrt(Float64(Float64(-0.5 / a) * Float64(g + sqrt(Float64(Float64(h + g) * Float64(g - h)))))) + cbrt(Float64(Float64(-0.5 / a) * Float64(g - g)))); end return tmp end
code[g_, h_, a_] := If[LessEqual[g, 1e-180], N[(N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(N[Sqrt[N[(N[(g * g), $MachinePrecision] - N[(h * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(g - g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(N[(-0.5 / a), $MachinePrecision] * N[(g + N[Sqrt[N[(N[(h + g), $MachinePrecision] * N[(g - h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(N[(-0.5 / a), $MachinePrecision] * N[(g - g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;g \leq 10^{-180}:\\
\;\;\;\;\sqrt[3]{\frac{0.5}{a} \cdot \left(\sqrt{g \cdot g - h \cdot h} - g\right)} + \sqrt[3]{\frac{0.5}{a} \cdot \left(g - g\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{\frac{-0.5}{a} \cdot \left(g + \sqrt{\left(h + g\right) \cdot \left(g - h\right)}\right)} + \sqrt[3]{\frac{-0.5}{a} \cdot \left(g - g\right)}\\
\end{array}
\end{array}
if g < 1e-180Initial program 38.7%
associate-/r*38.7%
metadata-eval38.7%
+-commutative38.7%
unsub-neg38.7%
associate-/r*38.7%
metadata-eval38.7%
Simplified38.7%
Taylor expanded in g around -inf 39.6%
neg-mul-138.4%
Simplified39.6%
if 1e-180 < g Initial program 43.6%
Simplified43.6%
Taylor expanded in g around inf 44.5%
Final simplification42.0%
(FPCore (g h a) :precision binary64 (+ (cbrt (* (/ -0.5 a) (+ g (sqrt (* (+ h g) (- g h)))))) (cbrt (* (/ -0.5 a) (- g g)))))
double code(double g, double h, double a) {
return cbrt(((-0.5 / a) * (g + sqrt(((h + g) * (g - h)))))) + cbrt(((-0.5 / a) * (g - g)));
}
public static double code(double g, double h, double a) {
return Math.cbrt(((-0.5 / a) * (g + Math.sqrt(((h + g) * (g - h)))))) + Math.cbrt(((-0.5 / a) * (g - g)));
}
function code(g, h, a) return Float64(cbrt(Float64(Float64(-0.5 / a) * Float64(g + sqrt(Float64(Float64(h + g) * Float64(g - h)))))) + cbrt(Float64(Float64(-0.5 / a) * Float64(g - g)))) end
code[g_, h_, a_] := N[(N[Power[N[(N[(-0.5 / a), $MachinePrecision] * N[(g + N[Sqrt[N[(N[(h + g), $MachinePrecision] * N[(g - h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(N[(-0.5 / a), $MachinePrecision] * N[(g - g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{-0.5}{a} \cdot \left(g + \sqrt{\left(h + g\right) \cdot \left(g - h\right)}\right)} + \sqrt[3]{\frac{-0.5}{a} \cdot \left(g - g\right)}
\end{array}
Initial program 41.1%
Simplified41.1%
Taylor expanded in g around inf 22.9%
Final simplification22.9%
(FPCore (g h a) :precision binary64 (+ (cbrt (* (- g (sqrt (* (+ h g) (- g h)))) (/ -0.5 a))) (cbrt (* (/ -0.5 a) (+ g g)))))
double code(double g, double h, double a) {
return cbrt(((g - sqrt(((h + g) * (g - h)))) * (-0.5 / a))) + cbrt(((-0.5 / a) * (g + g)));
}
public static double code(double g, double h, double a) {
return Math.cbrt(((g - Math.sqrt(((h + g) * (g - h)))) * (-0.5 / a))) + Math.cbrt(((-0.5 / a) * (g + g)));
}
function code(g, h, a) return Float64(cbrt(Float64(Float64(g - sqrt(Float64(Float64(h + g) * Float64(g - h)))) * Float64(-0.5 / a))) + cbrt(Float64(Float64(-0.5 / a) * Float64(g + g)))) end
code[g_, h_, a_] := N[(N[Power[N[(N[(g - N[Sqrt[N[(N[(h + g), $MachinePrecision] * N[(g - h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(-0.5 / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(N[(-0.5 / a), $MachinePrecision] * N[(g + g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\left(g - \sqrt{\left(h + g\right) \cdot \left(g - h\right)}\right) \cdot \frac{-0.5}{a}} + \sqrt[3]{\frac{-0.5}{a} \cdot \left(g + g\right)}
\end{array}
Initial program 41.1%
Simplified41.1%
Taylor expanded in g around inf 26.3%
Final simplification26.3%
herbie shell --seed 2023175
(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))))))))