
(FPCore (g a) :precision binary64 (cbrt (/ g (* 2.0 a))))
double code(double g, double a) {
return cbrt((g / (2.0 * a)));
}
public static double code(double g, double a) {
return Math.cbrt((g / (2.0 * a)));
}
function code(g, a) return cbrt(Float64(g / Float64(2.0 * a))) end
code[g_, a_] := N[Power[N[(g / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{g}{2 \cdot a}}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (g a) :precision binary64 (cbrt (/ g (* 2.0 a))))
double code(double g, double a) {
return cbrt((g / (2.0 * a)));
}
public static double code(double g, double a) {
return Math.cbrt((g / (2.0 * a)));
}
function code(g, a) return cbrt(Float64(g / Float64(2.0 * a))) end
code[g_, a_] := N[Power[N[(g / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{g}{2 \cdot a}}
\end{array}
(FPCore (g a) :precision binary64 (* (/ 1.0 (cbrt (/ -2.0 g))) (/ 1.0 (cbrt (- a)))))
double code(double g, double a) {
return (1.0 / cbrt((-2.0 / g))) * (1.0 / cbrt(-a));
}
public static double code(double g, double a) {
return (1.0 / Math.cbrt((-2.0 / g))) * (1.0 / Math.cbrt(-a));
}
function code(g, a) return Float64(Float64(1.0 / cbrt(Float64(-2.0 / g))) * Float64(1.0 / cbrt(Float64(-a)))) end
code[g_, a_] := N[(N[(1.0 / N[Power[N[(-2.0 / g), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[Power[(-a), 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt[3]{\frac{-2}{g}}} \cdot \frac{1}{\sqrt[3]{-a}}
\end{array}
Initial program 77.6%
lift-cbrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
cbrt-divN/A
frac-2negN/A
cbrt-divN/A
pow1/3N/A
associate-/l/N/A
neg-mul-1N/A
cbrt-prodN/A
pow1/3N/A
times-fracN/A
pow1/3N/A
Applied rewrites98.6%
lift-cbrt.f64N/A
lift-*.f64N/A
metadata-evalN/A
associate-/r/N/A
metadata-evalN/A
distribute-neg-fracN/A
lift-/.f64N/A
cbrt-divN/A
metadata-evalN/A
lower-/.f64N/A
lower-cbrt.f64N/A
lift-/.f64N/A
distribute-neg-fracN/A
metadata-evalN/A
lower-/.f6498.7
Applied rewrites98.7%
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lift-cbrt.f64N/A
lift-cbrt.f64N/A
cbrt-undivN/A
div-invN/A
metadata-evalN/A
*-commutativeN/A
neg-mul-1N/A
lift-neg.f64N/A
lower-cbrt.f6498.7
Applied rewrites98.7%
Final simplification98.7%
(FPCore (g a) :precision binary64 (/ (cbrt (/ -1.0 a)) (cbrt (/ -2.0 g))))
double code(double g, double a) {
return cbrt((-1.0 / a)) / cbrt((-2.0 / g));
}
public static double code(double g, double a) {
return Math.cbrt((-1.0 / a)) / Math.cbrt((-2.0 / g));
}
function code(g, a) return Float64(cbrt(Float64(-1.0 / a)) / cbrt(Float64(-2.0 / g))) end
code[g_, a_] := N[(N[Power[N[(-1.0 / a), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[N[(-2.0 / g), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sqrt[3]{\frac{-1}{a}}}{\sqrt[3]{\frac{-2}{g}}}
\end{array}
Initial program 77.6%
lift-cbrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
cbrt-divN/A
frac-2negN/A
cbrt-divN/A
pow1/3N/A
associate-/l/N/A
neg-mul-1N/A
cbrt-prodN/A
pow1/3N/A
times-fracN/A
pow1/3N/A
Applied rewrites98.6%
lift-*.f64N/A
lift-cbrt.f64N/A
lift-*.f64N/A
metadata-evalN/A
associate-/r/N/A
metadata-evalN/A
distribute-neg-fracN/A
lift-/.f64N/A
cbrt-divN/A
metadata-evalN/A
div-invN/A
lower-/.f64N/A
lift-/.f64N/A
lift-cbrt.f64N/A
lift-cbrt.f64N/A
cbrt-undivN/A
lower-cbrt.f64N/A
lower-/.f64N/A
lower-cbrt.f64N/A
lift-/.f64N/A
distribute-neg-fracN/A
metadata-evalN/A
lower-/.f6498.7
Applied rewrites98.7%
(FPCore (g a) :precision binary64 (/ (- -1.0) (* (cbrt (/ -2.0 g)) (cbrt (- a)))))
double code(double g, double a) {
return -(-1.0) / (cbrt((-2.0 / g)) * cbrt(-a));
}
public static double code(double g, double a) {
return -(-1.0) / (Math.cbrt((-2.0 / g)) * Math.cbrt(-a));
}
function code(g, a) return Float64(Float64(-(-1.0)) / Float64(cbrt(Float64(-2.0 / g)) * cbrt(Float64(-a)))) end
code[g_, a_] := N[((--1.0) / N[(N[Power[N[(-2.0 / g), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[(-a), 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{--1}{\sqrt[3]{\frac{-2}{g}} \cdot \sqrt[3]{-a}}
\end{array}
Initial program 77.6%
lift-cbrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
cbrt-divN/A
frac-2negN/A
cbrt-divN/A
pow1/3N/A
associate-/l/N/A
neg-mul-1N/A
cbrt-prodN/A
pow1/3N/A
times-fracN/A
pow1/3N/A
Applied rewrites98.6%
lift-*.f64N/A
lift-cbrt.f64N/A
lift-*.f64N/A
metadata-evalN/A
associate-/r/N/A
metadata-evalN/A
distribute-neg-fracN/A
lift-/.f64N/A
cbrt-divN/A
metadata-evalN/A
div-invN/A
lift-/.f64N/A
clear-numN/A
frac-2negN/A
metadata-evalN/A
associate-/l/N/A
lower-/.f64N/A
lower-*.f64N/A
Applied rewrites98.6%
Final simplification98.6%
(FPCore (g a) :precision binary64 (if (<= (* 2.0 a) -5e-305) (* (pow (- a) -0.3333333333333333) (cbrt (* -0.5 g))) (* (cbrt (* 0.5 g)) (pow a -0.3333333333333333))))
double code(double g, double a) {
double tmp;
if ((2.0 * a) <= -5e-305) {
tmp = pow(-a, -0.3333333333333333) * cbrt((-0.5 * g));
} else {
tmp = cbrt((0.5 * g)) * pow(a, -0.3333333333333333);
}
return tmp;
}
public static double code(double g, double a) {
double tmp;
if ((2.0 * a) <= -5e-305) {
tmp = Math.pow(-a, -0.3333333333333333) * Math.cbrt((-0.5 * g));
} else {
tmp = Math.cbrt((0.5 * g)) * Math.pow(a, -0.3333333333333333);
}
return tmp;
}
function code(g, a) tmp = 0.0 if (Float64(2.0 * a) <= -5e-305) tmp = Float64((Float64(-a) ^ -0.3333333333333333) * cbrt(Float64(-0.5 * g))); else tmp = Float64(cbrt(Float64(0.5 * g)) * (a ^ -0.3333333333333333)); end return tmp end
code[g_, a_] := If[LessEqual[N[(2.0 * a), $MachinePrecision], -5e-305], N[(N[Power[(-a), -0.3333333333333333], $MachinePrecision] * N[Power[N[(-0.5 * g), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(0.5 * g), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[a, -0.3333333333333333], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;2 \cdot a \leq -5 \cdot 10^{-305}:\\
\;\;\;\;{\left(-a\right)}^{-0.3333333333333333} \cdot \sqrt[3]{-0.5 \cdot g}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{0.5 \cdot g} \cdot {a}^{-0.3333333333333333}\\
\end{array}
\end{array}
if (*.f64 #s(literal 2 binary64) a) < -4.99999999999999985e-305Initial program 72.7%
lift-cbrt.f64N/A
pow1/3N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
frac-2negN/A
div-invN/A
unpow-prod-downN/A
div-invN/A
distribute-lft-neg-inN/A
pow-prod-downN/A
sqr-powN/A
pow-prod-downN/A
sqr-negN/A
remove-double-negN/A
remove-double-negN/A
pow-prod-downN/A
sqr-powN/A
unpow-prod-downN/A
div-invN/A
pow1/3N/A
inv-powN/A
pow-powN/A
Applied rewrites92.3%
if -4.99999999999999985e-305 < (*.f64 #s(literal 2 binary64) a) Initial program 82.6%
lift-cbrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
cbrt-divN/A
frac-2negN/A
cbrt-divN/A
pow1/3N/A
associate-/l/N/A
neg-mul-1N/A
cbrt-prodN/A
pow1/3N/A
times-fracN/A
pow1/3N/A
Applied rewrites98.6%
lift-*.f64N/A
lift-/.f64N/A
lift-cbrt.f64N/A
lift-cbrt.f64N/A
cbrt-undivN/A
lift-cbrt.f64N/A
cbrt-unprodN/A
lift-*.f64N/A
associate-*r*N/A
metadata-evalN/A
div-invN/A
div-invN/A
lift-/.f64N/A
neg-mul-1N/A
metadata-evalN/A
frac-2negN/A
associate-/r/N/A
lift-/.f64N/A
div-invN/A
lift-/.f64N/A
clear-numN/A
cbrt-prodN/A
Applied rewrites92.5%
Final simplification92.4%
(FPCore (g a) :precision binary64 (if (<= (* 2.0 a) -5e-305) (cbrt (/ (* (- g) (sqrt (/ -0.5 a))) (sqrt (* -2.0 a)))) (* (cbrt (* 0.5 g)) (pow a -0.3333333333333333))))
double code(double g, double a) {
double tmp;
if ((2.0 * a) <= -5e-305) {
tmp = cbrt(((-g * sqrt((-0.5 / a))) / sqrt((-2.0 * a))));
} else {
tmp = cbrt((0.5 * g)) * pow(a, -0.3333333333333333);
}
return tmp;
}
public static double code(double g, double a) {
double tmp;
if ((2.0 * a) <= -5e-305) {
tmp = Math.cbrt(((-g * Math.sqrt((-0.5 / a))) / Math.sqrt((-2.0 * a))));
} else {
tmp = Math.cbrt((0.5 * g)) * Math.pow(a, -0.3333333333333333);
}
return tmp;
}
function code(g, a) tmp = 0.0 if (Float64(2.0 * a) <= -5e-305) tmp = cbrt(Float64(Float64(Float64(-g) * sqrt(Float64(-0.5 / a))) / sqrt(Float64(-2.0 * a)))); else tmp = Float64(cbrt(Float64(0.5 * g)) * (a ^ -0.3333333333333333)); end return tmp end
code[g_, a_] := If[LessEqual[N[(2.0 * a), $MachinePrecision], -5e-305], N[Power[N[(N[((-g) * N[Sqrt[N[(-0.5 / a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(-2.0 * a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], N[(N[Power[N[(0.5 * g), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[a, -0.3333333333333333], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;2 \cdot a \leq -5 \cdot 10^{-305}:\\
\;\;\;\;\sqrt[3]{\frac{\left(-g\right) \cdot \sqrt{\frac{-0.5}{a}}}{\sqrt{-2 \cdot a}}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{0.5 \cdot g} \cdot {a}^{-0.3333333333333333}\\
\end{array}
\end{array}
if (*.f64 #s(literal 2 binary64) a) < -4.99999999999999985e-305Initial program 72.7%
lift-/.f64N/A
frac-2negN/A
clear-numN/A
associate-/r/N/A
inv-powN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
pow-prod-upN/A
pow-prod-downN/A
sqr-negN/A
remove-double-negN/A
remove-double-negN/A
pow2N/A
pow-powN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
inv-powN/A
Applied rewrites72.7%
lift-*.f64N/A
lift-neg.f64N/A
distribute-rgt-neg-outN/A
lift-/.f64N/A
metadata-evalN/A
associate-/r*N/A
lift-*.f64N/A
associate-/r/N/A
clear-numN/A
lift-/.f64N/A
rem-square-sqrtN/A
lift-sqrt.f64N/A
lift-/.f64N/A
sqrt-divN/A
associate-*r/N/A
distribute-neg-frac2N/A
lower-/.f64N/A
Applied rewrites72.8%
if -4.99999999999999985e-305 < (*.f64 #s(literal 2 binary64) a) Initial program 82.6%
lift-cbrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
cbrt-divN/A
frac-2negN/A
cbrt-divN/A
pow1/3N/A
associate-/l/N/A
neg-mul-1N/A
cbrt-prodN/A
pow1/3N/A
times-fracN/A
pow1/3N/A
Applied rewrites98.6%
lift-*.f64N/A
lift-/.f64N/A
lift-cbrt.f64N/A
lift-cbrt.f64N/A
cbrt-undivN/A
lift-cbrt.f64N/A
cbrt-unprodN/A
lift-*.f64N/A
associate-*r*N/A
metadata-evalN/A
div-invN/A
div-invN/A
lift-/.f64N/A
neg-mul-1N/A
metadata-evalN/A
frac-2negN/A
associate-/r/N/A
lift-/.f64N/A
div-invN/A
lift-/.f64N/A
clear-numN/A
cbrt-prodN/A
Applied rewrites92.5%
Final simplification82.6%
(FPCore (g a) :precision binary64 (* (cbrt g) (cbrt (/ 0.5 a))))
double code(double g, double a) {
return cbrt(g) * cbrt((0.5 / a));
}
public static double code(double g, double a) {
return Math.cbrt(g) * Math.cbrt((0.5 / a));
}
function code(g, a) return Float64(cbrt(g) * cbrt(Float64(0.5 / a))) end
code[g_, a_] := N[(N[Power[g, 1/3], $MachinePrecision] * N[Power[N[(0.5 / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{g} \cdot \sqrt[3]{\frac{0.5}{a}}
\end{array}
Initial program 77.6%
lift-cbrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
cbrt-divN/A
frac-2negN/A
cbrt-divN/A
pow1/3N/A
associate-/l/N/A
neg-mul-1N/A
cbrt-prodN/A
pow1/3N/A
times-fracN/A
pow1/3N/A
Applied rewrites98.6%
lift-*.f64N/A
lift-cbrt.f64N/A
pow1/3N/A
lift-*.f64N/A
unpow-prod-downN/A
associate-*r*N/A
lift-/.f64N/A
lift-cbrt.f64N/A
lift-cbrt.f64N/A
cbrt-undivN/A
pow1/3N/A
pow-prod-downN/A
metadata-evalN/A
div-invN/A
div-invN/A
lift-/.f64N/A
neg-mul-1N/A
metadata-evalN/A
frac-2negN/A
lower-*.f64N/A
Applied rewrites98.6%
Final simplification98.6%
(FPCore (g a) :precision binary64 (/ 1.0 (cbrt (/ (* 2.0 a) g))))
double code(double g, double a) {
return 1.0 / cbrt(((2.0 * a) / g));
}
public static double code(double g, double a) {
return 1.0 / Math.cbrt(((2.0 * a) / g));
}
function code(g, a) return Float64(1.0 / cbrt(Float64(Float64(2.0 * a) / g))) end
code[g_, a_] := N[(1.0 / N[Power[N[(N[(2.0 * a), $MachinePrecision] / g), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt[3]{\frac{2 \cdot a}{g}}}
\end{array}
Initial program 77.6%
lift-cbrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
cbrt-divN/A
frac-2negN/A
cbrt-divN/A
pow1/3N/A
associate-/l/N/A
neg-mul-1N/A
cbrt-prodN/A
pow1/3N/A
times-fracN/A
pow1/3N/A
Applied rewrites98.6%
lift-cbrt.f64N/A
lift-*.f64N/A
metadata-evalN/A
associate-/r/N/A
metadata-evalN/A
distribute-neg-fracN/A
lift-/.f64N/A
cbrt-divN/A
metadata-evalN/A
lower-/.f64N/A
lower-cbrt.f64N/A
lift-/.f64N/A
distribute-neg-fracN/A
metadata-evalN/A
lower-/.f6498.7
Applied rewrites98.7%
lift-*.f64N/A
lift-/.f64N/A
un-div-invN/A
lift-cbrt.f64N/A
lift-/.f64N/A
cbrt-divN/A
pow1/3N/A
associate-/r/N/A
Applied rewrites77.8%
(FPCore (g a) :precision binary64 (/ 1.0 (cbrt (* (/ a g) 2.0))))
double code(double g, double a) {
return 1.0 / cbrt(((a / g) * 2.0));
}
public static double code(double g, double a) {
return 1.0 / Math.cbrt(((a / g) * 2.0));
}
function code(g, a) return Float64(1.0 / cbrt(Float64(Float64(a / g) * 2.0))) end
code[g_, a_] := N[(1.0 / N[Power[N[(N[(a / g), $MachinePrecision] * 2.0), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt[3]{\frac{a}{g} \cdot 2}}
\end{array}
Initial program 77.6%
lift-cbrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
cbrt-divN/A
frac-2negN/A
cbrt-divN/A
pow1/3N/A
associate-/l/N/A
neg-mul-1N/A
cbrt-prodN/A
pow1/3N/A
times-fracN/A
pow1/3N/A
Applied rewrites98.6%
lift-*.f64N/A
lift-/.f64N/A
lift-cbrt.f64N/A
lift-cbrt.f64N/A
cbrt-undivN/A
lift-cbrt.f64N/A
cbrt-unprodN/A
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
div-invN/A
frac-timesN/A
*-commutativeN/A
times-fracN/A
lift-/.f64N/A
metadata-evalN/A
metadata-evalN/A
div-invN/A
cbrt-undivN/A
lift-cbrt.f64N/A
lift-cbrt.f64N/A
clear-numN/A
lower-/.f64N/A
lift-cbrt.f64N/A
lift-cbrt.f64N/A
cbrt-undivN/A
Applied rewrites77.8%
(FPCore (g a) :precision binary64 (cbrt (/ g (* 2.0 a))))
double code(double g, double a) {
return cbrt((g / (2.0 * a)));
}
public static double code(double g, double a) {
return Math.cbrt((g / (2.0 * a)));
}
function code(g, a) return cbrt(Float64(g / Float64(2.0 * a))) end
code[g_, a_] := N[Power[N[(g / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{g}{2 \cdot a}}
\end{array}
Initial program 77.6%
(FPCore (g a) :precision binary64 (cbrt (* (/ 0.5 a) g)))
double code(double g, double a) {
return cbrt(((0.5 / a) * g));
}
public static double code(double g, double a) {
return Math.cbrt(((0.5 / a) * g));
}
function code(g, a) return cbrt(Float64(Float64(0.5 / a) * g)) end
code[g_, a_] := N[Power[N[(N[(0.5 / a), $MachinePrecision] * g), $MachinePrecision], 1/3], $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{0.5}{a} \cdot g}
\end{array}
Initial program 77.6%
lift-cbrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
cbrt-divN/A
frac-2negN/A
cbrt-divN/A
pow1/3N/A
associate-/l/N/A
neg-mul-1N/A
cbrt-prodN/A
pow1/3N/A
times-fracN/A
pow1/3N/A
Applied rewrites98.6%
lift-*.f64N/A
lift-/.f64N/A
lift-cbrt.f64N/A
lift-cbrt.f64N/A
cbrt-undivN/A
lift-cbrt.f64N/A
cbrt-unprodN/A
lift-*.f64N/A
associate-*r*N/A
metadata-evalN/A
div-invN/A
div-invN/A
lift-/.f64N/A
neg-mul-1N/A
metadata-evalN/A
frac-2negN/A
associate-/r/N/A
lift-/.f64N/A
lift-/.f64N/A
lift-cbrt.f6477.6
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
lower-*.f64N/A
Applied rewrites77.6%
herbie shell --seed 2024240
(FPCore (g a)
:name "2-ancestry mixing, zero discriminant"
:precision binary64
(cbrt (/ g (* 2.0 a))))