
(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 9 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 (* (cbrt (* g -0.5)) (cbrt (/ -1.0 a))))
double code(double g, double a) {
return cbrt((g * -0.5)) * cbrt((-1.0 / a));
}
public static double code(double g, double a) {
return Math.cbrt((g * -0.5)) * Math.cbrt((-1.0 / a));
}
function code(g, a) return Float64(cbrt(Float64(g * -0.5)) * cbrt(Float64(-1.0 / a))) end
code[g_, a_] := N[(N[Power[N[(g * -0.5), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[N[(-1.0 / a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{g \cdot -0.5} \cdot \sqrt[3]{\frac{-1}{a}}
\end{array}
Initial program 74.9%
lift-cbrt.f64N/A
lift-/.f64N/A
cbrt-divN/A
lower-/.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f6498.7
Applied rewrites98.7%
lift-/.f64N/A
lift-cbrt.f64N/A
lift-cbrt.f64N/A
cbrt-undivN/A
lift-*.f64N/A
associate-/l/N/A
div-invN/A
metadata-evalN/A
*-commutativeN/A
metadata-evalN/A
times-fracN/A
metadata-evalN/A
associate-/r/N/A
lift-/.f64N/A
neg-mul-1N/A
lift-neg.f64N/A
div-invN/A
cbrt-prodN/A
lower-*.f64N/A
Applied rewrites98.8%
(FPCore (g a) :precision binary64 (if (<= (* a 2.0) -5e-308) (* (cbrt (- g)) (pow (* a -2.0) -0.3333333333333333)) (* (cbrt g) (pow (* a 2.0) -0.3333333333333333))))
double code(double g, double a) {
double tmp;
if ((a * 2.0) <= -5e-308) {
tmp = cbrt(-g) * pow((a * -2.0), -0.3333333333333333);
} else {
tmp = cbrt(g) * pow((a * 2.0), -0.3333333333333333);
}
return tmp;
}
public static double code(double g, double a) {
double tmp;
if ((a * 2.0) <= -5e-308) {
tmp = Math.cbrt(-g) * Math.pow((a * -2.0), -0.3333333333333333);
} else {
tmp = Math.cbrt(g) * Math.pow((a * 2.0), -0.3333333333333333);
}
return tmp;
}
function code(g, a) tmp = 0.0 if (Float64(a * 2.0) <= -5e-308) tmp = Float64(cbrt(Float64(-g)) * (Float64(a * -2.0) ^ -0.3333333333333333)); else tmp = Float64(cbrt(g) * (Float64(a * 2.0) ^ -0.3333333333333333)); end return tmp end
code[g_, a_] := If[LessEqual[N[(a * 2.0), $MachinePrecision], -5e-308], N[(N[Power[(-g), 1/3], $MachinePrecision] * N[Power[N[(a * -2.0), $MachinePrecision], -0.3333333333333333], $MachinePrecision]), $MachinePrecision], N[(N[Power[g, 1/3], $MachinePrecision] * N[Power[N[(a * 2.0), $MachinePrecision], -0.3333333333333333], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot 2 \leq -5 \cdot 10^{-308}:\\
\;\;\;\;\sqrt[3]{-g} \cdot {\left(a \cdot -2\right)}^{-0.3333333333333333}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{g} \cdot {\left(a \cdot 2\right)}^{-0.3333333333333333}\\
\end{array}
\end{array}
if (*.f64 #s(literal 2 binary64) a) < -4.99999999999999955e-308Initial program 72.4%
lift-cbrt.f64N/A
lift-/.f64N/A
cbrt-divN/A
lower-/.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f6498.7
Applied rewrites98.7%
lift-/.f64N/A
lift-cbrt.f64N/A
lift-cbrt.f64N/A
cbrt-undivN/A
lift-*.f64N/A
associate-/l/N/A
div-invN/A
metadata-evalN/A
*-commutativeN/A
metadata-evalN/A
times-fracN/A
metadata-evalN/A
associate-/r/N/A
lift-/.f64N/A
neg-mul-1N/A
lift-neg.f64N/A
div-invN/A
cbrt-prodN/A
lower-*.f64N/A
Applied rewrites98.7%
lift-*.f64N/A
metadata-evalN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-inN/A
metadata-evalN/A
div-invN/A
clear-numN/A
metadata-evalN/A
remove-double-divN/A
metadata-evalN/A
frac-2negN/A
lift-/.f64N/A
lower-/.f64N/A
metadata-evalN/A
lift-/.f64N/A
frac-2negN/A
metadata-evalN/A
remove-double-divN/A
neg-mul-1N/A
associate-/r*N/A
metadata-evalN/A
metadata-evalN/A
lower-/.f64N/A
metadata-eval98.8
Applied rewrites98.8%
Applied rewrites92.2%
if -4.99999999999999955e-308 < (*.f64 #s(literal 2 binary64) a) Initial program 77.2%
lift-cbrt.f64N/A
lift-/.f64N/A
div-invN/A
cbrt-prodN/A
pow1/3N/A
*-commutativeN/A
lower-*.f64N/A
inv-powN/A
pow-powN/A
lower-pow.f64N/A
metadata-evalN/A
lower-cbrt.f6492.6
Applied rewrites92.6%
Final simplification92.4%
(FPCore (g a) :precision binary64 (if (<= (* a 2.0) -5e-308) (* (cbrt (* g -0.5)) (pow (- a) -0.3333333333333333)) (* (cbrt g) (pow (* a 2.0) -0.3333333333333333))))
double code(double g, double a) {
double tmp;
if ((a * 2.0) <= -5e-308) {
tmp = cbrt((g * -0.5)) * pow(-a, -0.3333333333333333);
} else {
tmp = cbrt(g) * pow((a * 2.0), -0.3333333333333333);
}
return tmp;
}
public static double code(double g, double a) {
double tmp;
if ((a * 2.0) <= -5e-308) {
tmp = Math.cbrt((g * -0.5)) * Math.pow(-a, -0.3333333333333333);
} else {
tmp = Math.cbrt(g) * Math.pow((a * 2.0), -0.3333333333333333);
}
return tmp;
}
function code(g, a) tmp = 0.0 if (Float64(a * 2.0) <= -5e-308) tmp = Float64(cbrt(Float64(g * -0.5)) * (Float64(-a) ^ -0.3333333333333333)); else tmp = Float64(cbrt(g) * (Float64(a * 2.0) ^ -0.3333333333333333)); end return tmp end
code[g_, a_] := If[LessEqual[N[(a * 2.0), $MachinePrecision], -5e-308], N[(N[Power[N[(g * -0.5), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[(-a), -0.3333333333333333], $MachinePrecision]), $MachinePrecision], N[(N[Power[g, 1/3], $MachinePrecision] * N[Power[N[(a * 2.0), $MachinePrecision], -0.3333333333333333], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot 2 \leq -5 \cdot 10^{-308}:\\
\;\;\;\;\sqrt[3]{g \cdot -0.5} \cdot {\left(-a\right)}^{-0.3333333333333333}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{g} \cdot {\left(a \cdot 2\right)}^{-0.3333333333333333}\\
\end{array}
\end{array}
if (*.f64 #s(literal 2 binary64) a) < -4.99999999999999955e-308Initial program 72.4%
lift-cbrt.f64N/A
lift-/.f64N/A
cbrt-divN/A
lower-/.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f6498.7
Applied rewrites98.7%
lift-/.f64N/A
lift-cbrt.f64N/A
lift-cbrt.f64N/A
cbrt-undivN/A
lift-*.f64N/A
associate-/l/N/A
div-invN/A
metadata-evalN/A
*-commutativeN/A
metadata-evalN/A
times-fracN/A
metadata-evalN/A
associate-/r/N/A
lift-/.f64N/A
neg-mul-1N/A
lift-neg.f64N/A
div-invN/A
cbrt-prodN/A
lower-*.f64N/A
Applied rewrites98.7%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6498.7
lift-cbrt.f64N/A
pow1/3N/A
lift-/.f64N/A
frac-2negN/A
metadata-evalN/A
inv-powN/A
pow-powN/A
metadata-evalN/A
metadata-evalN/A
lower-pow.f64N/A
lower-neg.f64N/A
metadata-eval92.2
Applied rewrites92.2%
if -4.99999999999999955e-308 < (*.f64 #s(literal 2 binary64) a) Initial program 77.2%
lift-cbrt.f64N/A
lift-/.f64N/A
div-invN/A
cbrt-prodN/A
pow1/3N/A
*-commutativeN/A
lower-*.f64N/A
inv-powN/A
pow-powN/A
lower-pow.f64N/A
metadata-evalN/A
lower-cbrt.f6492.6
Applied rewrites92.6%
Final simplification92.4%
(FPCore (g a) :precision binary64 (if (<= (* a 2.0) 1.5e-291) (cbrt (* g (/ 0.5 a))) (* (cbrt g) (pow (* a 2.0) -0.3333333333333333))))
double code(double g, double a) {
double tmp;
if ((a * 2.0) <= 1.5e-291) {
tmp = cbrt((g * (0.5 / a)));
} else {
tmp = cbrt(g) * pow((a * 2.0), -0.3333333333333333);
}
return tmp;
}
public static double code(double g, double a) {
double tmp;
if ((a * 2.0) <= 1.5e-291) {
tmp = Math.cbrt((g * (0.5 / a)));
} else {
tmp = Math.cbrt(g) * Math.pow((a * 2.0), -0.3333333333333333);
}
return tmp;
}
function code(g, a) tmp = 0.0 if (Float64(a * 2.0) <= 1.5e-291) tmp = cbrt(Float64(g * Float64(0.5 / a))); else tmp = Float64(cbrt(g) * (Float64(a * 2.0) ^ -0.3333333333333333)); end return tmp end
code[g_, a_] := If[LessEqual[N[(a * 2.0), $MachinePrecision], 1.5e-291], N[Power[N[(g * N[(0.5 / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], N[(N[Power[g, 1/3], $MachinePrecision] * N[Power[N[(a * 2.0), $MachinePrecision], -0.3333333333333333], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot 2 \leq 1.5 \cdot 10^{-291}:\\
\;\;\;\;\sqrt[3]{g \cdot \frac{0.5}{a}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{g} \cdot {\left(a \cdot 2\right)}^{-0.3333333333333333}\\
\end{array}
\end{array}
if (*.f64 #s(literal 2 binary64) a) < 1.5e-291Initial program 72.8%
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
lower-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
metadata-eval72.8
Applied rewrites72.8%
if 1.5e-291 < (*.f64 #s(literal 2 binary64) a) Initial program 76.9%
lift-cbrt.f64N/A
lift-/.f64N/A
div-invN/A
cbrt-prodN/A
pow1/3N/A
*-commutativeN/A
lower-*.f64N/A
inv-powN/A
pow-powN/A
lower-pow.f64N/A
metadata-evalN/A
lower-cbrt.f6492.6
Applied rewrites92.6%
Final simplification82.9%
(FPCore (g a) :precision binary64 (if (<= (* a 2.0) 1.5e-291) (cbrt (* g (/ 0.5 a))) (* (pow a -0.3333333333333333) (cbrt (* g 0.5)))))
double code(double g, double a) {
double tmp;
if ((a * 2.0) <= 1.5e-291) {
tmp = cbrt((g * (0.5 / a)));
} else {
tmp = pow(a, -0.3333333333333333) * cbrt((g * 0.5));
}
return tmp;
}
public static double code(double g, double a) {
double tmp;
if ((a * 2.0) <= 1.5e-291) {
tmp = Math.cbrt((g * (0.5 / a)));
} else {
tmp = Math.pow(a, -0.3333333333333333) * Math.cbrt((g * 0.5));
}
return tmp;
}
function code(g, a) tmp = 0.0 if (Float64(a * 2.0) <= 1.5e-291) tmp = cbrt(Float64(g * Float64(0.5 / a))); else tmp = Float64((a ^ -0.3333333333333333) * cbrt(Float64(g * 0.5))); end return tmp end
code[g_, a_] := If[LessEqual[N[(a * 2.0), $MachinePrecision], 1.5e-291], N[Power[N[(g * N[(0.5 / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], N[(N[Power[a, -0.3333333333333333], $MachinePrecision] * N[Power[N[(g * 0.5), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot 2 \leq 1.5 \cdot 10^{-291}:\\
\;\;\;\;\sqrt[3]{g \cdot \frac{0.5}{a}}\\
\mathbf{else}:\\
\;\;\;\;{a}^{-0.3333333333333333} \cdot \sqrt[3]{g \cdot 0.5}\\
\end{array}
\end{array}
if (*.f64 #s(literal 2 binary64) a) < 1.5e-291Initial program 72.8%
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
lower-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
metadata-eval72.8
Applied rewrites72.8%
if 1.5e-291 < (*.f64 #s(literal 2 binary64) a) Initial program 76.9%
lift-cbrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
div-invN/A
cbrt-prodN/A
pow1/3N/A
*-commutativeN/A
lower-*.f64N/A
inv-powN/A
pow-powN/A
lower-pow.f64N/A
metadata-evalN/A
lower-cbrt.f64N/A
div-invN/A
lower-*.f64N/A
metadata-eval92.6
Applied rewrites92.6%
Final simplification82.9%
(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(Float64(-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 74.9%
lift-cbrt.f64N/A
lift-/.f64N/A
cbrt-divN/A
lower-/.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f6498.7
Applied rewrites98.7%
lift-/.f64N/A
div-invN/A
*-commutativeN/A
lift-cbrt.f64N/A
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
div-invN/A
cbrt-divN/A
pow1/3N/A
lift-cbrt.f64N/A
clear-numN/A
associate-/r/N/A
lift-cbrt.f64N/A
pow1/3N/A
lift-cbrt.f64N/A
cbrt-divN/A
lift-/.f64N/A
cbrt-undivN/A
lift-/.f64N/A
frac-2negN/A
lift-neg.f64N/A
associate-/r/N/A
cbrt-prodN/A
Applied rewrites98.7%
(FPCore (g a) :precision binary64 (/ (cbrt g) (cbrt (* a 2.0))))
double code(double g, double a) {
return cbrt(g) / cbrt((a * 2.0));
}
public static double code(double g, double a) {
return Math.cbrt(g) / Math.cbrt((a * 2.0));
}
function code(g, a) return Float64(cbrt(g) / cbrt(Float64(a * 2.0))) end
code[g_, a_] := N[(N[Power[g, 1/3], $MachinePrecision] / N[Power[N[(a * 2.0), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sqrt[3]{g}}{\sqrt[3]{a \cdot 2}}
\end{array}
Initial program 74.9%
lift-cbrt.f64N/A
lift-/.f64N/A
cbrt-divN/A
lower-/.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f6498.7
Applied rewrites98.7%
Final simplification98.7%
(FPCore (g a) :precision binary64 (if (<= (/ g (* a 2.0)) 1e+294) (cbrt (* g (/ 0.5 a))) (/ (cbrt (* g (* 0.5 (* a a)))) a)))
double code(double g, double a) {
double tmp;
if ((g / (a * 2.0)) <= 1e+294) {
tmp = cbrt((g * (0.5 / a)));
} else {
tmp = cbrt((g * (0.5 * (a * a)))) / a;
}
return tmp;
}
public static double code(double g, double a) {
double tmp;
if ((g / (a * 2.0)) <= 1e+294) {
tmp = Math.cbrt((g * (0.5 / a)));
} else {
tmp = Math.cbrt((g * (0.5 * (a * a)))) / a;
}
return tmp;
}
function code(g, a) tmp = 0.0 if (Float64(g / Float64(a * 2.0)) <= 1e+294) tmp = cbrt(Float64(g * Float64(0.5 / a))); else tmp = Float64(cbrt(Float64(g * Float64(0.5 * Float64(a * a)))) / a); end return tmp end
code[g_, a_] := If[LessEqual[N[(g / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], 1e+294], N[Power[N[(g * N[(0.5 / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], N[(N[Power[N[(g * N[(0.5 * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] / a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{g}{a \cdot 2} \leq 10^{+294}:\\
\;\;\;\;\sqrt[3]{g \cdot \frac{0.5}{a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt[3]{g \cdot \left(0.5 \cdot \left(a \cdot a\right)\right)}}{a}\\
\end{array}
\end{array}
if (/.f64 g (*.f64 #s(literal 2 binary64) a)) < 1.00000000000000007e294Initial program 79.6%
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
lower-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
metadata-eval79.6
Applied rewrites79.6%
if 1.00000000000000007e294 < (/.f64 g (*.f64 #s(literal 2 binary64) a)) Initial program 4.5%
lift-cbrt.f64N/A
lift-/.f64N/A
cbrt-divN/A
lower-/.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f6498.5
Applied rewrites98.5%
lift-/.f64N/A
lift-cbrt.f64N/A
lift-cbrt.f64N/A
cbrt-undivN/A
lift-*.f64N/A
associate-/l/N/A
div-invN/A
metadata-evalN/A
*-commutativeN/A
metadata-evalN/A
times-fracN/A
metadata-evalN/A
associate-/r/N/A
lift-/.f64N/A
neg-mul-1N/A
lift-neg.f64N/A
div-invN/A
cbrt-prodN/A
lower-*.f64N/A
Applied rewrites99.1%
lift-*.f64N/A
metadata-evalN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-inN/A
metadata-evalN/A
div-invN/A
clear-numN/A
metadata-evalN/A
remove-double-divN/A
metadata-evalN/A
frac-2negN/A
lift-/.f64N/A
lower-/.f64N/A
metadata-evalN/A
lift-/.f64N/A
frac-2negN/A
metadata-evalN/A
remove-double-divN/A
neg-mul-1N/A
associate-/r*N/A
metadata-evalN/A
metadata-evalN/A
lower-/.f64N/A
metadata-eval99.2
Applied rewrites99.2%
Applied rewrites44.6%
Final simplification77.4%
(FPCore (g a) :precision binary64 (cbrt (* g (/ 0.5 a))))
double code(double g, double a) {
return cbrt((g * (0.5 / a)));
}
public static double code(double g, double a) {
return Math.cbrt((g * (0.5 / a)));
}
function code(g, a) return cbrt(Float64(g * Float64(0.5 / a))) end
code[g_, a_] := N[Power[N[(g * N[(0.5 / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{g \cdot \frac{0.5}{a}}
\end{array}
Initial program 74.9%
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
lower-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
metadata-eval74.9
Applied rewrites74.9%
Final simplification74.9%
herbie shell --seed 2024237
(FPCore (g a)
:name "2-ancestry mixing, zero discriminant"
:precision binary64
(cbrt (/ g (* 2.0 a))))