
(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 7 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 a)))
double code(double g, double a) {
return cbrt((g * 0.5)) / cbrt(a);
}
public static double code(double g, double a) {
return Math.cbrt((g * 0.5)) / Math.cbrt(a);
}
function code(g, a) return Float64(cbrt(Float64(g * 0.5)) / cbrt(a)) end
code[g_, a_] := N[(N[Power[N[(g * 0.5), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sqrt[3]{g \cdot 0.5}}{\sqrt[3]{a}}
\end{array}
Initial program 74.0%
associate-/r*N/A
cbrt-divN/A
lower-/.f64N/A
lower-cbrt.f64N/A
div-invN/A
lower-*.f64N/A
metadata-evalN/A
lower-cbrt.f6498.7
Applied egg-rr98.7%
(FPCore (g a) :precision binary64 (if (<= (* a 2.0) -5e-307) (* (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-307) {
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-307) {
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-307) 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-307], 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^{-307}:\\
\;\;\;\;\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) < -5.00000000000000014e-307Initial program 73.9%
lift-*.f64N/A
cbrt-divN/A
frac-2negN/A
neg-mul-1N/A
lift-*.f64N/A
*-commutativeN/A
cbrt-prodN/A
distribute-rgt-neg-inN/A
times-fracN/A
distribute-neg-frac2N/A
cbrt-divN/A
lower-*.f64N/A
lower-/.f64N/A
lower-cbrt.f64N/A
lower-neg.f64N/A
lower-cbrt.f64N/A
div-invN/A
lower-*.f64N/A
metadata-eval98.8
Applied egg-rr98.8%
Applied egg-rr92.0%
if -5.00000000000000014e-307 < (*.f64 #s(literal 2 binary64) a) Initial program 74.2%
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.1
Applied egg-rr92.1%
Final simplification92.0%
(FPCore (g a) :precision binary64 (if (<= (* a 2.0) 1e-278) (/ 1.0 (cbrt (* a (/ 2.0 g)))) (* (cbrt g) (pow (* a 2.0) -0.3333333333333333))))
double code(double g, double a) {
double tmp;
if ((a * 2.0) <= 1e-278) {
tmp = 1.0 / cbrt((a * (2.0 / g)));
} 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) <= 1e-278) {
tmp = 1.0 / Math.cbrt((a * (2.0 / g)));
} 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) <= 1e-278) tmp = Float64(1.0 / cbrt(Float64(a * Float64(2.0 / g)))); 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], 1e-278], N[(1.0 / N[Power[N[(a * N[(2.0 / g), $MachinePrecision]), $MachinePrecision], 1/3], $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 10^{-278}:\\
\;\;\;\;\frac{1}{\sqrt[3]{a \cdot \frac{2}{g}}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{g} \cdot {\left(a \cdot 2\right)}^{-0.3333333333333333}\\
\end{array}
\end{array}
if (*.f64 #s(literal 2 binary64) a) < 9.99999999999999938e-279Initial program 74.5%
lift-*.f64N/A
div-invN/A
inv-powN/A
sqr-powN/A
sqr-powN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
pow-powN/A
pow2N/A
remove-double-negN/A
remove-double-negN/A
sqr-negN/A
pow-prod-downN/A
pow-prod-upN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
inv-powN/A
Applied egg-rr37.1%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l/N/A
clear-numN/A
associate-/r*N/A
clear-numN/A
un-div-invN/A
clear-numN/A
lift-/.f64N/A
*-commutativeN/A
lift-/.f64N/A
associate-*l/N/A
clear-numN/A
cbrt-divN/A
metadata-evalN/A
lower-/.f64N/A
Applied egg-rr37.4%
lift-*.f64N/A
lift-*.f64N/A
associate-*l/N/A
lift-*.f64N/A
*-commutativeN/A
times-fracN/A
lift-*.f64N/A
associate-/l*N/A
*-inversesN/A
*-rgt-identityN/A
metadata-evalN/A
associate-/r*N/A
associate-/l/N/A
lift-/.f64N/A
lower-*.f64N/A
lift-/.f64N/A
associate-/l/N/A
associate-/r*N/A
metadata-evalN/A
lower-/.f6474.6
Applied egg-rr74.6%
if 9.99999999999999938e-279 < (*.f64 #s(literal 2 binary64) a) Initial program 73.6%
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.1
Applied egg-rr92.1%
Final simplification83.4%
(FPCore (g a) :precision binary64 (if (<= (* a 2.0) 1e-278) (/ 1.0 (cbrt (* a (/ 2.0 g)))) (* (cbrt (* g 0.5)) (pow a -0.3333333333333333))))
double code(double g, double a) {
double tmp;
if ((a * 2.0) <= 1e-278) {
tmp = 1.0 / cbrt((a * (2.0 / g)));
} else {
tmp = cbrt((g * 0.5)) * pow(a, -0.3333333333333333);
}
return tmp;
}
public static double code(double g, double a) {
double tmp;
if ((a * 2.0) <= 1e-278) {
tmp = 1.0 / Math.cbrt((a * (2.0 / g)));
} else {
tmp = Math.cbrt((g * 0.5)) * Math.pow(a, -0.3333333333333333);
}
return tmp;
}
function code(g, a) tmp = 0.0 if (Float64(a * 2.0) <= 1e-278) tmp = Float64(1.0 / cbrt(Float64(a * Float64(2.0 / g)))); else tmp = Float64(cbrt(Float64(g * 0.5)) * (a ^ -0.3333333333333333)); end return tmp end
code[g_, a_] := If[LessEqual[N[(a * 2.0), $MachinePrecision], 1e-278], N[(1.0 / N[Power[N[(a * N[(2.0 / g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(g * 0.5), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[a, -0.3333333333333333], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot 2 \leq 10^{-278}:\\
\;\;\;\;\frac{1}{\sqrt[3]{a \cdot \frac{2}{g}}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{g \cdot 0.5} \cdot {a}^{-0.3333333333333333}\\
\end{array}
\end{array}
if (*.f64 #s(literal 2 binary64) a) < 9.99999999999999938e-279Initial program 74.5%
lift-*.f64N/A
div-invN/A
inv-powN/A
sqr-powN/A
sqr-powN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
pow-powN/A
pow2N/A
remove-double-negN/A
remove-double-negN/A
sqr-negN/A
pow-prod-downN/A
pow-prod-upN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
inv-powN/A
Applied egg-rr37.1%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l/N/A
clear-numN/A
associate-/r*N/A
clear-numN/A
un-div-invN/A
clear-numN/A
lift-/.f64N/A
*-commutativeN/A
lift-/.f64N/A
associate-*l/N/A
clear-numN/A
cbrt-divN/A
metadata-evalN/A
lower-/.f64N/A
Applied egg-rr37.4%
lift-*.f64N/A
lift-*.f64N/A
associate-*l/N/A
lift-*.f64N/A
*-commutativeN/A
times-fracN/A
lift-*.f64N/A
associate-/l*N/A
*-inversesN/A
*-rgt-identityN/A
metadata-evalN/A
associate-/r*N/A
associate-/l/N/A
lift-/.f64N/A
lower-*.f64N/A
lift-/.f64N/A
associate-/l/N/A
associate-/r*N/A
metadata-evalN/A
lower-/.f6474.6
Applied egg-rr74.6%
if 9.99999999999999938e-279 < (*.f64 #s(literal 2 binary64) a) Initial program 73.6%
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.1
Applied egg-rr92.1%
Final simplification83.4%
(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.0%
lift-*.f64N/A
cbrt-divN/A
lower-/.f64N/A
lower-cbrt.f64N/A
lower-cbrt.f6498.7
Applied egg-rr98.7%
Final simplification98.7%
(FPCore (g a) :precision binary64 (cbrt (/ g (* a 2.0))))
double code(double g, double a) {
return cbrt((g / (a * 2.0)));
}
public static double code(double g, double a) {
return Math.cbrt((g / (a * 2.0)));
}
function code(g, a) return cbrt(Float64(g / Float64(a * 2.0))) end
code[g_, a_] := N[Power[N[(g / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\frac{g}{a \cdot 2}}
\end{array}
Initial program 74.0%
Final simplification74.0%
(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.0%
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.0
Applied egg-rr74.0%
Final simplification74.0%
herbie shell --seed 2024211
(FPCore (g a)
:name "2-ancestry mixing, zero discriminant"
:precision binary64
(cbrt (/ g (* 2.0 a))))