
(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 8 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 (/ -1.0 (pow a -1.0)))) (cbrt (* g -0.5))))
double code(double g, double a) {
return (-(-1.0) / cbrt((-1.0 / pow(a, -1.0)))) * cbrt((g * -0.5));
}
public static double code(double g, double a) {
return (-(-1.0) / Math.cbrt((-1.0 / Math.pow(a, -1.0)))) * Math.cbrt((g * -0.5));
}
function code(g, a) return Float64(Float64(Float64(-(-1.0)) / cbrt(Float64(-1.0 / (a ^ -1.0)))) * cbrt(Float64(g * -0.5))) end
code[g_, a_] := N[(N[((--1.0) / N[Power[N[(-1.0 / N[Power[a, -1.0], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision] * N[Power[N[(g * -0.5), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{--1}{\sqrt[3]{\frac{-1}{{a}^{-1}}}} \cdot \sqrt[3]{g \cdot -0.5}
\end{array}
Initial program 73.5%
lift-cbrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
frac-2negN/A
cbrt-divN/A
distribute-neg-fracN/A
cbrt-divN/A
pow1/3N/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
pow1/3N/A
cbrt-divN/A
pow1/3N/A
lower-/.f64N/A
Applied rewrites98.7%
lift-/.f64N/A
frac-2negN/A
div-invN/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
neg-mul-1N/A
associate-/r*N/A
metadata-evalN/A
metadata-evalN/A
lower-/.f64N/A
lower-neg.f6498.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6498.7
Applied rewrites98.7%
rem-cube-cbrtN/A
pow1/3N/A
pow-powN/A
metadata-evalN/A
metadata-evalN/A
pow-powN/A
inv-powN/A
unpow-1N/A
metadata-evalN/A
metadata-evalN/A
lift-neg.f64N/A
distribute-frac-neg2N/A
metadata-evalN/A
frac-2negN/A
lower-/.f64N/A
inv-powN/A
lower-pow.f6498.7
Applied rewrites98.7%
Final simplification98.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(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 73.5%
lift-cbrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
frac-2negN/A
cbrt-divN/A
distribute-neg-fracN/A
cbrt-divN/A
pow1/3N/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
pow1/3N/A
cbrt-divN/A
pow1/3N/A
lower-/.f64N/A
Applied rewrites98.7%
lift-/.f64N/A
frac-2negN/A
div-invN/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
neg-mul-1N/A
associate-/r*N/A
metadata-evalN/A
metadata-evalN/A
lower-/.f64N/A
lower-neg.f6498.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6498.7
Applied rewrites98.7%
rem-cube-cbrtN/A
pow1/3N/A
pow-powN/A
metadata-evalN/A
metadata-evalN/A
pow-powN/A
inv-powN/A
unpow-1N/A
metadata-evalN/A
metadata-evalN/A
lift-neg.f64N/A
distribute-frac-neg2N/A
metadata-evalN/A
frac-2negN/A
lower-/.f64N/A
inv-powN/A
lower-pow.f6498.7
Applied rewrites98.7%
Applied rewrites98.7%
Final simplification98.7%
(FPCore (g a) :precision binary64 (if (<= (* 2.0 a) -4e-307) (* (pow (- a) -0.3333333333333333) (cbrt (* -0.5 g))) (* (* -1.0 (pow a -0.3333333333333333)) (cbrt (* g -0.5)))))
double code(double g, double a) {
double tmp;
if ((2.0 * a) <= -4e-307) {
tmp = pow(-a, -0.3333333333333333) * cbrt((-0.5 * g));
} else {
tmp = (-1.0 * pow(a, -0.3333333333333333)) * cbrt((g * -0.5));
}
return tmp;
}
public static double code(double g, double a) {
double tmp;
if ((2.0 * a) <= -4e-307) {
tmp = Math.pow(-a, -0.3333333333333333) * Math.cbrt((-0.5 * g));
} else {
tmp = (-1.0 * Math.pow(a, -0.3333333333333333)) * Math.cbrt((g * -0.5));
}
return tmp;
}
function code(g, a) tmp = 0.0 if (Float64(2.0 * a) <= -4e-307) tmp = Float64((Float64(-a) ^ -0.3333333333333333) * cbrt(Float64(-0.5 * g))); else tmp = Float64(Float64(-1.0 * (a ^ -0.3333333333333333)) * cbrt(Float64(g * -0.5))); end return tmp end
code[g_, a_] := If[LessEqual[N[(2.0 * a), $MachinePrecision], -4e-307], N[(N[Power[(-a), -0.3333333333333333], $MachinePrecision] * N[Power[N[(-0.5 * g), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(N[(-1.0 * N[Power[a, -0.3333333333333333], $MachinePrecision]), $MachinePrecision] * N[Power[N[(g * -0.5), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;2 \cdot a \leq -4 \cdot 10^{-307}:\\
\;\;\;\;{\left(-a\right)}^{-0.3333333333333333} \cdot \sqrt[3]{-0.5 \cdot g}\\
\mathbf{else}:\\
\;\;\;\;\left(-1 \cdot {a}^{-0.3333333333333333}\right) \cdot \sqrt[3]{g \cdot -0.5}\\
\end{array}
\end{array}
if (*.f64 #s(literal 2 binary64) a) < -3.99999999999999964e-307Initial program 76.8%
Applied rewrites98.6%
lift-cbrt.f64N/A
pow1/3N/A
lift-/.f64N/A
frac-2negN/A
metadata-evalN/A
lift-neg.f64N/A
inv-powN/A
pow-powN/A
metadata-evalN/A
lower-pow.f6492.3
Applied rewrites92.3%
if -3.99999999999999964e-307 < (*.f64 #s(literal 2 binary64) a) Initial program 70.4%
lift-cbrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
frac-2negN/A
cbrt-divN/A
distribute-neg-fracN/A
cbrt-divN/A
pow1/3N/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
pow1/3N/A
cbrt-divN/A
pow1/3N/A
lower-/.f64N/A
Applied rewrites98.7%
lift-/.f64N/A
frac-2negN/A
div-invN/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
neg-mul-1N/A
associate-/r*N/A
metadata-evalN/A
metadata-evalN/A
lower-/.f64N/A
lower-neg.f6498.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6498.6
Applied rewrites98.6%
lift-/.f64N/A
clear-numN/A
inv-powN/A
metadata-evalN/A
pow-prod-upN/A
pow-prod-downN/A
Applied rewrites92.0%
Final simplification92.1%
(FPCore (g a) :precision binary64 (if (<= (* 2.0 a) 1e-301) (/ -1.0 (cbrt (/ (* -2.0 a) g))) (* (* -1.0 (pow a -0.3333333333333333)) (cbrt (* g -0.5)))))
double code(double g, double a) {
double tmp;
if ((2.0 * a) <= 1e-301) {
tmp = -1.0 / cbrt(((-2.0 * a) / g));
} else {
tmp = (-1.0 * pow(a, -0.3333333333333333)) * cbrt((g * -0.5));
}
return tmp;
}
public static double code(double g, double a) {
double tmp;
if ((2.0 * a) <= 1e-301) {
tmp = -1.0 / Math.cbrt(((-2.0 * a) / g));
} else {
tmp = (-1.0 * Math.pow(a, -0.3333333333333333)) * Math.cbrt((g * -0.5));
}
return tmp;
}
function code(g, a) tmp = 0.0 if (Float64(2.0 * a) <= 1e-301) tmp = Float64(-1.0 / cbrt(Float64(Float64(-2.0 * a) / g))); else tmp = Float64(Float64(-1.0 * (a ^ -0.3333333333333333)) * cbrt(Float64(g * -0.5))); end return tmp end
code[g_, a_] := If[LessEqual[N[(2.0 * a), $MachinePrecision], 1e-301], N[(-1.0 / N[Power[N[(N[(-2.0 * a), $MachinePrecision] / g), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(N[(-1.0 * N[Power[a, -0.3333333333333333], $MachinePrecision]), $MachinePrecision] * N[Power[N[(g * -0.5), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;2 \cdot a \leq 10^{-301}:\\
\;\;\;\;\frac{-1}{\sqrt[3]{\frac{-2 \cdot a}{g}}}\\
\mathbf{else}:\\
\;\;\;\;\left(-1 \cdot {a}^{-0.3333333333333333}\right) \cdot \sqrt[3]{g \cdot -0.5}\\
\end{array}
\end{array}
if (*.f64 #s(literal 2 binary64) a) < 1.00000000000000007e-301Initial program 77.4%
lift-cbrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
frac-2negN/A
cbrt-divN/A
distribute-neg-fracN/A
cbrt-divN/A
pow1/3N/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
pow1/3N/A
cbrt-divN/A
pow1/3N/A
lower-/.f64N/A
Applied rewrites98.7%
lift-/.f64N/A
lift-cbrt.f64N/A
lift-cbrt.f64N/A
cbrt-undivN/A
pow1/3N/A
lift-*.f64N/A
associate-/l*N/A
unpow-prod-downN/A
clear-numN/A
lift-neg.f64N/A
neg-mul-1N/A
associate-*l/N/A
lift-/.f64N/A
unpow-prod-downN/A
div-invN/A
associate-/l/N/A
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
unpow-prod-downN/A
lower-*.f64N/A
Applied rewrites98.7%
Applied rewrites78.0%
if 1.00000000000000007e-301 < (*.f64 #s(literal 2 binary64) a) Initial program 69.8%
lift-cbrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
frac-2negN/A
cbrt-divN/A
distribute-neg-fracN/A
cbrt-divN/A
pow1/3N/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
pow1/3N/A
cbrt-divN/A
pow1/3N/A
lower-/.f64N/A
Applied rewrites98.7%
lift-/.f64N/A
frac-2negN/A
div-invN/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
neg-mul-1N/A
associate-/r*N/A
metadata-evalN/A
metadata-evalN/A
lower-/.f64N/A
lower-neg.f6498.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6498.6
Applied rewrites98.6%
lift-/.f64N/A
clear-numN/A
inv-powN/A
metadata-evalN/A
pow-prod-upN/A
pow-prod-downN/A
Applied rewrites92.0%
Final simplification85.2%
(FPCore (g a) :precision binary64 (* (cbrt (/ 0.5 a)) (cbrt g)))
double code(double g, double a) {
return cbrt((0.5 / a)) * cbrt(g);
}
public static double code(double g, double a) {
return Math.cbrt((0.5 / a)) * Math.cbrt(g);
}
function code(g, a) return Float64(cbrt(Float64(0.5 / a)) * cbrt(g)) end
code[g_, a_] := N[(N[Power[N[(0.5 / a), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[g, 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{0.5}{a}} \cdot \sqrt[3]{g}
\end{array}
Initial program 73.5%
lift-cbrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
frac-2negN/A
cbrt-divN/A
distribute-neg-fracN/A
cbrt-divN/A
pow1/3N/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
pow1/3N/A
cbrt-divN/A
pow1/3N/A
lower-/.f64N/A
Applied rewrites98.7%
lift-/.f64N/A
lift-cbrt.f64N/A
lift-cbrt.f64N/A
cbrt-undivN/A
pow1/3N/A
lift-*.f64N/A
associate-/l*N/A
unpow-prod-downN/A
clear-numN/A
lift-neg.f64N/A
neg-mul-1N/A
associate-*l/N/A
lift-/.f64N/A
unpow-prod-downN/A
div-invN/A
associate-/l/N/A
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
unpow-prod-downN/A
lower-*.f64N/A
Applied rewrites98.7%
(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 73.5%
lift-cbrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
frac-2negN/A
cbrt-divN/A
distribute-neg-fracN/A
cbrt-divN/A
pow1/3N/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
pow1/3N/A
cbrt-divN/A
pow1/3N/A
lower-/.f64N/A
Applied rewrites98.7%
lift-/.f64N/A
lift-cbrt.f64N/A
lift-cbrt.f64N/A
cbrt-undivN/A
pow1/3N/A
lift-*.f64N/A
associate-/l*N/A
unpow-prod-downN/A
clear-numN/A
lift-neg.f64N/A
neg-mul-1N/A
associate-*l/N/A
lift-/.f64N/A
unpow-prod-downN/A
div-invN/A
associate-/l/N/A
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
unpow-prod-downN/A
lower-*.f64N/A
Applied rewrites98.7%
Applied rewrites73.6%
(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 73.5%
(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 73.5%
lift-/.f64N/A
frac-2negN/A
div-invN/A
*-commutativeN/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 rewrites73.5%
lift-*.f64N/A
lift-neg.f64N/A
distribute-rgt-neg-outN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lift-/.f64N/A
distribute-neg-fracN/A
metadata-evalN/A
lower-/.f6473.5
Applied rewrites73.5%
herbie shell --seed 2024322
(FPCore (g a)
:name "2-ancestry mixing, zero discriminant"
:precision binary64
(cbrt (/ g (* 2.0 a))))