
(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 7 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.5%
Simplified47.5%
cbrt-prod52.8%
difference-of-squares52.8%
fma-neg52.8%
fma-neg52.8%
difference-of-squares52.8%
difference-of-squares52.8%
sub-neg52.8%
add-sqr-sqrt52.8%
hypot-def53.5%
distribute-rgt-neg-in53.5%
Applied egg-rr53.5%
*-commutative53.5%
Simplified53.5%
if 0.0 < (*.f64 h h) Initial program 39.5%
Simplified39.5%
pow1/239.5%
difference-of-squares39.5%
Applied egg-rr39.5%
unpow1/239.5%
Simplified39.5%
Final simplification45.3%
(FPCore (g h a) :precision binary64 (let* ((t_0 (sqrt (* (+ h g) (- g h))))) (+ (cbrt (* (- g t_0) (/ -0.5 a))) (cbrt (* (/ -0.5 a) (+ g t_0))))))
double code(double g, double h, double a) {
double t_0 = sqrt(((h + g) * (g - h)));
return cbrt(((g - t_0) * (-0.5 / a))) + cbrt(((-0.5 / a) * (g + t_0)));
}
public static double code(double g, double h, double a) {
double t_0 = Math.sqrt(((h + g) * (g - h)));
return Math.cbrt(((g - t_0) * (-0.5 / a))) + Math.cbrt(((-0.5 / a) * (g + t_0)));
}
function code(g, h, a) t_0 = sqrt(Float64(Float64(h + g) * Float64(g - h))) return Float64(cbrt(Float64(Float64(g - t_0) * Float64(-0.5 / a))) + cbrt(Float64(Float64(-0.5 / a) * Float64(g + t_0)))) end
code[g_, h_, a_] := Block[{t$95$0 = N[Sqrt[N[(N[(h + g), $MachinePrecision] * N[(g - h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[(N[Power[N[(N[(g - t$95$0), $MachinePrecision] * N[(-0.5 / a), $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)}\\
\sqrt[3]{\left(g - t_0\right) \cdot \frac{-0.5}{a}} + \sqrt[3]{\frac{-0.5}{a} \cdot \left(g + t_0\right)}
\end{array}
\end{array}
Initial program 42.8%
Simplified42.8%
Final simplification42.8%
(FPCore (g h a) :precision binary64 (+ (cbrt (* (/ -0.5 a) (- g (sqrt (- (* g g) (* h h)))))) (cbrt (* (/ -0.5 a) (+ g (sqrt (* (+ h g) (- g h))))))))
double code(double g, double h, double a) {
return cbrt(((-0.5 / a) * (g - sqrt(((g * g) - (h * h)))))) + cbrt(((-0.5 / a) * (g + sqrt(((h + g) * (g - h))))));
}
public static double code(double g, double h, double a) {
return Math.cbrt(((-0.5 / a) * (g - Math.sqrt(((g * g) - (h * h)))))) + Math.cbrt(((-0.5 / a) * (g + Math.sqrt(((h + g) * (g - h))))));
}
function code(g, h, a) return 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 + sqrt(Float64(Float64(h + g) * Float64(g - h))))))) end
code[g_, h_, a_] := 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 + N[Sqrt[N[(N[(h + g), $MachinePrecision] * N[(g - h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\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 + \sqrt{\left(h + g\right) \cdot \left(g - h\right)}\right)}
\end{array}
Initial program 42.8%
Simplified42.8%
pow1/242.8%
difference-of-squares42.8%
Applied egg-rr42.8%
unpow1/242.8%
Simplified42.8%
Final simplification42.8%
(FPCore (g h a)
:precision binary64
(let* ((t_0 (cbrt (* (/ 0.5 a) (- (- g) (sqrt (- (* g g) (* h h))))))))
(if (<= g -1.58e-162)
(+ (cbrt (* (/ 0.5 a) (* g -2.0))) t_0)
(+ t_0 (cbrt (* (/ 0.5 a) (* -0.5 (/ (* h h) g))))))))
double code(double g, double h, double a) {
double t_0 = cbrt(((0.5 / a) * (-g - sqrt(((g * g) - (h * h))))));
double tmp;
if (g <= -1.58e-162) {
tmp = cbrt(((0.5 / a) * (g * -2.0))) + t_0;
} else {
tmp = t_0 + cbrt(((0.5 / a) * (-0.5 * ((h * h) / g))));
}
return tmp;
}
public static double code(double g, double h, double a) {
double t_0 = Math.cbrt(((0.5 / a) * (-g - Math.sqrt(((g * g) - (h * h))))));
double tmp;
if (g <= -1.58e-162) {
tmp = Math.cbrt(((0.5 / a) * (g * -2.0))) + t_0;
} else {
tmp = t_0 + Math.cbrt(((0.5 / a) * (-0.5 * ((h * h) / g))));
}
return tmp;
}
function code(g, h, a) t_0 = cbrt(Float64(Float64(0.5 / a) * Float64(Float64(-g) - sqrt(Float64(Float64(g * g) - Float64(h * h)))))) tmp = 0.0 if (g <= -1.58e-162) tmp = Float64(cbrt(Float64(Float64(0.5 / a) * Float64(g * -2.0))) + t_0); else tmp = Float64(t_0 + cbrt(Float64(Float64(0.5 / a) * Float64(-0.5 * Float64(Float64(h * h) / g))))); end return tmp end
code[g_, h_, a_] := Block[{t$95$0 = 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]}, If[LessEqual[g, -1.58e-162], N[(N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(g * -2.0), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + t$95$0), $MachinePrecision], N[(t$95$0 + N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(-0.5 * N[(N[(h * h), $MachinePrecision] / g), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{\frac{0.5}{a} \cdot \left(\left(-g\right) - \sqrt{g \cdot g - h \cdot h}\right)}\\
\mathbf{if}\;g \leq -1.58 \cdot 10^{-162}:\\
\;\;\;\;\sqrt[3]{\frac{0.5}{a} \cdot \left(g \cdot -2\right)} + t_0\\
\mathbf{else}:\\
\;\;\;\;t_0 + \sqrt[3]{\frac{0.5}{a} \cdot \left(-0.5 \cdot \frac{h \cdot h}{g}\right)}\\
\end{array}
\end{array}
if g < -1.5800000000000001e-162Initial program 46.2%
associate-/r*46.2%
metadata-eval46.2%
+-commutative46.2%
unsub-neg46.2%
associate-/r*46.2%
metadata-eval46.2%
Simplified46.2%
Taylor expanded in g around -inf 45.1%
*-commutative45.1%
Simplified45.1%
if -1.5800000000000001e-162 < g Initial program 40.1%
associate-/r*40.1%
metadata-eval40.1%
+-commutative40.1%
unsub-neg40.1%
associate-/r*40.1%
metadata-eval40.1%
Simplified40.1%
Taylor expanded in g around inf 42.0%
unpow242.0%
Simplified42.0%
Final simplification43.4%
(FPCore (g h a)
:precision binary64
(if (<= g -1.58e-162)
(+
(cbrt (* (/ 0.5 a) (* g -2.0)))
(cbrt (* (/ 0.5 a) (- (- g) (sqrt (- (* g g) (* h h)))))))
(+
(cbrt (* (/ -0.5 a) (+ g (sqrt (* (+ h g) (- g h))))))
(cbrt (* 0.0 (/ -0.5 a))))))
double code(double g, double h, double a) {
double tmp;
if (g <= -1.58e-162) {
tmp = cbrt(((0.5 / a) * (g * -2.0))) + cbrt(((0.5 / a) * (-g - sqrt(((g * g) - (h * h))))));
} else {
tmp = cbrt(((-0.5 / a) * (g + sqrt(((h + g) * (g - h)))))) + cbrt((0.0 * (-0.5 / a)));
}
return tmp;
}
public static double code(double g, double h, double a) {
double tmp;
if (g <= -1.58e-162) {
tmp = Math.cbrt(((0.5 / a) * (g * -2.0))) + 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.0 * (-0.5 / a)));
}
return tmp;
}
function code(g, h, a) tmp = 0.0 if (g <= -1.58e-162) tmp = Float64(cbrt(Float64(Float64(0.5 / a) * Float64(g * -2.0))) + 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(0.0 * Float64(-0.5 / a)))); end return tmp end
code[g_, h_, a_] := If[LessEqual[g, -1.58e-162], N[(N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(g * -2.0), $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[(0.0 * N[(-0.5 / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;g \leq -1.58 \cdot 10^{-162}:\\
\;\;\;\;\sqrt[3]{\frac{0.5}{a} \cdot \left(g \cdot -2\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]{0 \cdot \frac{-0.5}{a}}\\
\end{array}
\end{array}
if g < -1.5800000000000001e-162Initial program 46.2%
associate-/r*46.2%
metadata-eval46.2%
+-commutative46.2%
unsub-neg46.2%
associate-/r*46.2%
metadata-eval46.2%
Simplified46.2%
Taylor expanded in g around -inf 45.1%
*-commutative45.1%
Simplified45.1%
if -1.5800000000000001e-162 < g Initial program 40.1%
Simplified40.1%
Taylor expanded in g around inf 41.0%
distribute-rgt1-in41.0%
metadata-eval41.0%
mul0-lft41.0%
metadata-eval41.0%
Simplified41.0%
Final simplification42.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 42.8%
Simplified42.8%
Taylor expanded in g around inf 26.7%
Final simplification26.7%
(FPCore (g h a) :precision binary64 (+ (cbrt (* (/ -0.5 a) (+ g (sqrt (* (+ h g) (- g h)))))) (cbrt (* 0.0 (/ -0.5 a)))))
double code(double g, double h, double a) {
return cbrt(((-0.5 / a) * (g + sqrt(((h + g) * (g - h)))))) + cbrt((0.0 * (-0.5 / a)));
}
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.0 * (-0.5 / a)));
}
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(0.0 * Float64(-0.5 / a)))) 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[(0.0 * N[(-0.5 / a), $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]{0 \cdot \frac{-0.5}{a}}
\end{array}
Initial program 42.8%
Simplified42.8%
Taylor expanded in g around inf 23.6%
distribute-rgt1-in23.6%
metadata-eval23.6%
mul0-lft23.6%
metadata-eval23.6%
Simplified23.6%
Final simplification23.6%
herbie shell --seed 2023192
(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))))))))